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

forms - Secure PHP File Upload Script -

PHP: Exploding array elements -

java - How do I override the spring framework version in Spring Batch? -