I am trying to find out if a href attr is empty do something, my code is as follows...
jQuery('#sidebar a').click(function() {
var bob = jQuery(this).attr("href");
if(jQuery(bob).attr() == "") {
alert('I am empty href value');
}
});
I am not sure where I am going wrong? Any advice? Thanks!
You're passing bob
into jQuery
as a selector. Just test it directly:
jQuery('#sidebar a').click(function() {
var bob = jQuery(this).attr("href");
if (bob == "") {
alert('I am empty href value');
}
});
Or better yet, just:
if (!bob) {