Home > Web Front-end > Front-end Q&A > What attributes are used in jquery

What attributes are used in jquery

青灯夜游
Release: 2022-06-10 16:04:13
Original
2231 people have browsed it

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.

What attributes are used in jquery

The operating environment of this tutorial: windows7 system, jquery3.6.0 version, Dell G3 computer.

Properties available in jquery

##MethodDescriptioncontextjqueryContains the version number of jQueryjQuery.fx .intervalChange the animation run rate in millisecondsjQuery.fx.offGlobally disable or enable all animationsjQuery.supportContains a set of properties representing different browser features or vulnerabilities (mainly for internal use of jQuery) lengthContains the number of elements in the jQuery objectjQuery.cssNumberAn object containing all CSS properties that can be used without units
Deprecated in version 1.10. Contains the original context passed to jQuery

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>
Copy after login

What attributes are used in jquery

jQuery.fx.interval property

jQuery.fx.interval property is used to change the animation running rate in milliseconds . Syntax:

jQuery.fx.interval = milliseconds;
Copy after login

ParameterDescriptionRequired. Specifies the animation run rate in milliseconds. The default is 13 milliseconds.
milliseconds
This property is often used to modify the number of frames per second that the animation runs. Lowering this value can make the animation run smoother in faster browsers, but doing so will impact performance and CPU.

Note: Since jQuery uses a global interval, in order for this property to take effect, the animation should no longer be running or all animations should be stopped first.

Note: This attribute is not valid in browsers that support the requestAnimationFrame attribute, such as Google Chrome 11.

Example: Run animation of
element in fewer frames

<!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>
Copy after login

What attributes are used in jquery

##jQuery.fx.off property

jQuery.fx.off property is used to globally disable or enable all animations. Syntax:

jQuery.fx.off = true|false;
Copy after login

Parameters truefalseThe default value is false, which allows the animation to run normally. When set to true, all animation methods are disabled, which sets the element to its final state rather than displaying the effect.
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 Properties

The 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
Copy after login

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>
Copy after login

What attributes are used in jquery

jQuery.cssNumber property

$.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 tutorial

, web front-end video]

The 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template