Thanks guys!
I had removed the post as I came up with a way to make it work.
This is what I eventually used:
if ($('horray_' + id).childNodes[1]){
var field_image = $('field_http_' + id).src;
}else{ var field_image = '';}
I wrapped the image in a span, and tested for the child node of the
span. There is only one child node, but firstchild would not work.
Thanks again.
Sheri
On Jun 9, 7:01 pm, tobie <[EMAIL PROTECTED]> wrote:
> I suggest you use $('field_http_' + id).hasAttribute('src') instead.
>
> On Jun 9, 5:54 pm, Ken Snyder <[EMAIL PROTECTED]> wrote:
>
> > muskokee wrote:
> > > ...
>
> > > my script is failing be cause not every row *has* a src to give me (i
> > > have left the empty img tag in for now - easier that way!) - therefore
> > > the var comes back as an error with "no properties".
>
> > > i am trying to use the empty() function to check whether there is a
> > > value in the src of the image like so:
>
> > > if ($('field_http_' + id).src.empty()){
> > > var field_image = 'no image';
> > > }else{
> > > var field_image = $('field_http_' + id).src;
>
> > > ...
>
> > > Error: $("field_http_" + id).src.empty is not a function
> > > ...
>
> > Hi Sheri,
>
> > I think you're pretty much there. Since empty() is a function of
> > string, when $("field_http_"+id).src is undefined, "undefined.empty"
> > will not be a function. $("field_http_"+id).src will return undefined
> > any time your img tag lacks a src. Try something like this:
>
> > var img = $('field_http_' + id);
> > if (img.src===undefined || img.src.empty()) {
> > // there is no value or a blank value for src} else {
>
> > // there is a non-empty string value for src
>
> > }
>
> > --Ken
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---