javascript - How to show/hide a jquery script only on Firefox -


trying show , hide js on firefox browser. there question detect firefox versions, not answer of question have asked question.

html:

<div id="about_me"> text color change </div> 

show on firefox:

$("#about_me").addclass("red"); 

i have trying not working:

<!--[if gecko ]> $("#about_me").addclass("red"); <![endif]--> 

and show other browsers , hide on firefox:

$("#about_me").addclass("blue"); 

how show js different browser, text color red on firefox , blue on other browsers.

please see fiddle >>
thanks.

try navigator.useragent used detect browser

the useragent property returns value of user-agent header sent browser server.

the value returned, contains information name, version , platform of browser.

if(navigator.useragent.tolowercase().indexof("firefox") > -1){     $("#about_me").addclass("red"); } else{         $("#about_me").addclass("blue");     } 

fiddle

about naviagate useragent | mdn

note : run fiddle in browsers. checked in chrome, safari, ie , firefox


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -