Query 允许链接(链式语法)。

来源:互联网 发布:淘宝客服售前售后 编辑:程序博客网 时间:2024/05/16 08:06
<!DOCTYPE html><html><head><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script><script>function myFunction(){$("#h01").attr("style","color:red").html("Hello jQuery")}$(document).ready(myFunction);</script></head><body><h1 id="h01"></h1></body></html>

亲自试一试

正如您在上面的例子中看到的,jQuery 允许链接(链式语法)。

链接(Chaining)是一种在同一对象上执行多个任务的便捷方法

提示:jQuery 返回 jQuery 对象,与已传递的 DOM 对象不同。jQuery 对象拥有的属性和方法,与 DOM 对象的不同。您不能在 jQuery 对象上使用 HTML DOM 的属性和方法。
0 0
原创粉丝点击