jquery - If a has attr rel=lightbox then addClass, problem -


i wonder why doesn't work?

var attr = $("a").attr('rel'); if (typeof attr == 'lightbox') {     $(this).addclass("lightbox"); } 

i want add class link has rel attribute set "lightbox".

this should work... right?

$('a[rel="lightbox"]').addclass("lightbox"); 

that should trick.

typeof - returns data type not value! trying compare type (string) value (lightbox).


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -