articles

Home / DeveloperSection / Articles / Getting Browser Version using JQuery

Getting Browser Version using JQuery

Vijay Shukla 5718 27-Dec-2012

In this article I have tried to explaining how to get browser version using JQuery.

JQuery provides a JQuery.browser property which is used for get version of your browser, and we also need the JQuery.each() method and .appendTo() method for getting the browser version and show its version on HTML application, we can also say that is the JQuery utilities.

JQuery.browser :

The JQuery.browser property provides information about the web browsers, it contains flags for four popular browsers classes (Internet Explorer, Mozilla, Webkit, and Opera) as well as version information.

JQuery.each():

This method is used to loop through each element of the target jQuery object. It’s  Very useful for multi elements DOM manipulation.

Syntax:
 $(selector).each(function(index, element))
.appendTo():

This method inserts HTML elements at the last of the selected DOM elements.

Syntax:
$(content).appendTo(selector)
 Style:
   <style>

   p { color:green; font-weight:bolder; margin:3px 0 0 10px; }
   div { color:blue; margin-left:20px; font-size:14px; }
   span { color:red; }
  </style>

 Script:

   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

   <script type="text/javascript" language="javascript">
 $(document).ready(function() {
    jQuery.each(jQuery.browser, function(i, val) {
      $("<div>" + i + " : <span>" + val + "</span>")
                .appendTo(document.body);
    });
   });
   </script>
   <style>
HTML Code:
  <p>Browser info:</p>
Output:

Getting Browser Version using JQuery


Updated 07-Sep-2019

Leave Comment

Comments

Liked By