您现在的位置是:首页 > 电脑技术查询 > web开发

jquery的get()方法,该如何解决

编辑:chaxungu时间:2022-10-02 23:15:54分类:web开发

jquery的get()方法
JScript code<html><head> <script type="text/javascript" src="jquery-1.5.2.min.js"></script> <script> $(function() { $("#test").click(function() { var tmp = $(this).get().innerHTML; alert(tmp); }); }) </script></head><body> <div id="test">aaa</div></body></html>

jQuery的get()方法不是获取的是DOM元素吗,为什么这段代码弹出的是undefined?

谢谢!

------解决方案--------------------
.....先去了解一下get()它到底是干什么的。。
------解决方案--------------------
顶2L $(this)获取到一个数组形式的jquery对象,jquery对象转换成DOM有两种方式$(this)[index],
$(this).get(index)必须说明你去的是哪个元素