jQuery if statement change div class to another not class -
is possible, use of if-statement change class of 1 div, example #carriage-promo, another, example #carriage-promo-2?
consider:
if(! navigator.useragent.match(/android/i) && ! navigator.useragent.match(/webos/i) && ! navigator.useragent.match(/iphone/i) && ! navigator.useragent.match(/ipod/i) && ! navigator.useragent.match(/ipad/i) && ! navigator.useragent.match(/blackberry/i) ) { $('#carriage-promo').css({'position':'fixed','bottom':'0px','width':'100%'}); } else { $('#carriage-promo').css({'display':'inline-block', 'height':'40px'}); alert('tablet detected'); //change #carriage-promo #carriage-promo-2 }
instead of changing 1 property of class, i'd change entire class 1 if user browsing 1 of above devices.
not sure if want change id or class attribute. if it's class, replace id class.
$('#carriage-promo').attr('id', 'carriage-promo-2');
or, if it's class want change, do
$('#carriage-promo').addclass('class_name');
Comments
Post a Comment