小白教程
所有教程
关于
Search
172.71.254.57
172.71.254.57
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Misc get”的源代码
本页内容
下一节:
Misc_index
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:get()}}[[Category:jquery ref misc|3]] = jQuery 杂项 get() 方法 = [[jquery ref misc|jQuery 杂项方法]] 获取第一个 <p> 元素的名称和值: <sample title="" desc="" lang="html" hererun="1"> $("button").click(function(){ x=$("p").get(0); $("div").text(x.nodeName + ": " + x.innerHTML); }); </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ x=$("p").get(0); $("div").text(x.nodeName + ": " + x.innerHTML); }); }); </script> </head> <body> <p>这是一个段落。</p> <button>获取P的DOM元素</button> <div></div> </body> </html> </run> == 定义和用法 == get() 方法获取由选择器指定的 DOM 元素。 == 语法 == <pre> $(selector).get(index)</pre> {| class="table table-striped table-hover" ! 参数 ! 描述 |- | index | 可选。规定要获取哪个匹配的元素(通过 index 编号)。 |} [[jquery ref misc|jQuery 杂项方法]]
返回至“
Misc get
”。
下一节:
Misc_index