How to show/hide a jquery script only on Firefox

Trying to show and hide js only on Firefox browser. There are another question about Detect all Firefox versions, but it is not answer of my question so i have asked this question.

HTML:

<div id="about_me">
This Text color will be change
</div>

Show this only on Firefox:

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

I have trying this but not working:

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

And Show this to other browsers and hide on Firefox:

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

How show JS to different browser, that text color will be red only on Firefox and blue on other browsers.

Please See this Fiddle >>
Thanks.


Source: cross-browser

Leave a Reply