Click here to Skip to main content
15,905,420 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<script type="text/javascript">

       $(document).ready(function () {

           $('#B').click(function () {


               if ($.browser.msie) {

                   alert("IE");
                   $('#info').css("background-color","yellow !important");
                   //alert("IE");
               }
               else if ($.browser.webkit) {
                   alert("Webkit");
                   $('#info').css("backgroundColor", "pink !important");

               }
               else if ($.browser.mozilla) {

                   alert("Mozilla");
                   $('#info').css("backgroundColor", "orange !important");
               }
               else {

                   alert("unknown");
               }



           });




       });

   </script>


   <div id="info"></div>

   <input  id="B" type="button" value="See Effect" />

Posted
Comments
SP HINGU 17-Feb-14 5:19am    
remove ' !important ' then it works
OPees 17-Feb-14 5:26am    
Right SP :)

1 solution

XML
<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>

JavaScript
<script type="text/javascript">
 
       $(document).ready(function () { 
           $('#B').click(function () { 
               if ($.browser.msie) { 
                   alert("IE");
                   $('#info').css("background-color","yellow");                  
               }
               else if ($.browser.webkit) {
                   alert("Webkit");                
                  $('#info').css("backgroundColor", "pink"); 
               }
               else if ($.browser.mozilla) { 
                   alert("Mozilla");
                   $('#info').css("backgroundColor", "orange");
               }
               else { 
                   alert("unknown");
               }
            });
       }); 
   </script> 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900