if statement - jquery - if href attr == "" -


i trying find out if href attr empty something, code follows...

jquery('#sidebar a').click(function() {       var bob = jquery(this).attr("href");       if(jquery(bob).attr() == "") {             alert('i empty href value');         }      }); 

i not sure going wrong? advice? thanks!

you're passing bob jquery selector. test directly:

jquery('#sidebar a').click(function() {      var bob = jquery(this).attr("href");      if (bob == "") {         alert('i empty href value');     }  }); 

or better yet, just:

    if (!bob) { 

gratuitous live example


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -