In jquery, the $.browser object allows you to get the name and version information of the browser, such as $.browser.chrome true, which means that the current Chrome browser, $. Browser.mozilla is true to indicate that it is currently a Firefox browser and can be $.browser.version to obtain browser version information.
- <div id= "Divtest" >
- <div class= "title" >
- <span class= "FL" > Get browser Name and version number </span>
- </div>
- <div class= "Content" ></div>
- </div>
- <script type= "Text/javascript" >
- $ (function () {
- var strtmp = "Your browser name is:";
- if ($.browser.chrome) {//Google browser
- Strtmp + + "Chrome";
- }
- if ($.browser.mozilla) {//Firefox related browser
- Strtmp + + "Mozilla FireFox";
- }
- Strtmp + = "<br/><br/> Version number is:"//Get version number
- +?;
- $ (". Content"). html (strtmp);
- });
- </script>
Detects if an object is empty
In jquery, you can invoke a tool function named $.isemptyobject to detect whether the contents of an object is empty, and if it is null, the function returns True, otherwise, the value of false is returned, and the calling format is as follows:
$.isemptyobject (obj);
Where the parameter obj represents the name of the object to be instrumented.
- <div id= "Divtest" >
- <div class= "title" >
- <span class= "FL" > Detect if the object is empty </span>
- </div>
- <div class= "Content" ></div>
- </div>
- <script type= "Text/javascript" >
- $ (function () {
- var obj = {"Name": "Tyrants"};
- var strtmp = "You defined one:";
- if ($.isemptyobject (obj)) {//Detect is empty
- Strtmp + = "Empty Object";
- }
- else {
- Strtmp + = "Non-empty object";
- }
- $ (". Content"). html (strtmp);
- });
- </script>
Detects if an object is a raw object
Invokes a tool function named $.isplainobject that detects whether the object is the original object created by the {} or the new object () keyword and, if so, returns True, otherwise, returns a value of FALSE, calling the format:
$.isplainobject (obj);
Where the parameter obj represents the name of the object to be instrumented.