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
-~----------~----~----~----~------~----~------~--~---