There are 7 properties available for jquery: 1. "jquery", which can output the version number of the jQuery library; 2. "jQuery.fx.interval", which can change the animation running rate in milliseconds; 3. "length", counts the number of elements in the jQuery object; 4. "context", etc.
The operating environment of this tutorial: windows7 system, jquery3.6.0 version, Dell G3 computer.
Properties available in jquery
Description | |
---|---|
Deprecated in version 1.10. Contains the original context passed to jQuery | |
Contains the version number of jQuery | |
Change the animation run rate in milliseconds | |
Globally disable or enable all animations | |
Contains a set of properties representing different browser features or vulnerabilities (mainly for internal use of jQuery) | |
Contains the number of elements in the jQuery object | |
An object containing all CSS properties that can be used without units |
jquery property
The string returned by the jquery property contains the version number of jQuery.<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="js/jquery-3.6.0.min.js"></script> <script> $(document).ready(function() { $("button").on("click", function() { var version = $().jquery; console.log("你正在运行的jQuery版本为: " + version); }); }); </script> </head> <body> <button>点我!</button> </body> </html>
jQuery.fx.interval property
jQuery.fx.interval property is used to change the animation running rate in milliseconds . Syntax:jQuery.fx.interval = milliseconds;
Description | |
---|---|
milliseconds | Required. Specifies the animation run rate in milliseconds. The default is 13 milliseconds.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="js/jquery-3.6.0.min.js"></script> <script> $(document).ready(function() { $("#toggle").on("click", function() { $("div").toggle(5000); }); $("#interval").on("click", function() { jQuery.fx.interval = 500; }); }); </script> </head> <body> <p>“div切换”按钮被按下时,我们在隐藏和显示div之间切换(默认是13毫秒)。每次“减少运行动画帧”按钮被按下,我们添加500毫秒的属性,这将导致以更少的帧运行动画(根据不同的浏览器,这可能导致动画运行流畅度低于期望)。</p> <p><b>注意:</b> 由于jQuery使用一个全局间隔,任何更改此属性生效,没有动画运行或者说动画都应该先停止运行(按“切换div”,然后当" div "完成动画时按“运行动画帧更少”。当动画已经停止,再次按“切换div”注意效果)。</p> <button id="toggle">div切换</button> <button id="interval">减少运行动画帧</button> <div style="background:#98bf21;height:100px;width:100px;margin:50px;"> </div> </body> </html>
jQuery.fx.off property is used to globally disable or enable all animations. Syntax:
jQuery.fx.off = true|false;
Description | |
---|---|
Specifies that animation should be disabled. | |
Default. Specifies that animation should be enabled. |
Tip: If you need to simplify the code, you can use $.fx.off instead of jQuery.fx.off.
jQuery.support PropertiesThe jQuery.support property contains a set of properties that represent different browser features or vulnerabilities.
This attribute is mainly used internally by jQuery.
length property (commonly used)The length property contains the number of elements in the jQuery object.
$(selector).length
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="js/jquery-3.6.0.min.js"></script> <script> $(document).ready(function() { $("button").click(function() { console.log($("li").length); }); }); </script> </head> <body> <button>输出li的数量</button> <ul> <li>Coffee</li> <li>Milk</li> <li>Soda</li> </ul> </body> </html>
$.cssNumber refers to all You can object without using the unit CSS property.
Tip: Used in .css() to determine if px needs to be appended to a unitless value.
[Recommended learning:
jQuery video tutorialThe above is the detailed content of What attributes are used in jquery. For more information, please follow other related articles on the PHP Chinese website!