jquery获取当前元素的值,比如获取button上的值

来源:互联网 发布:windows7优化设置 编辑:程序博客网 时间:2024/05/21 11:26
<html><head><script type="text/javascript" src="/jquery/jquery.js"></script><script type="text/javascript">$(document).ready(function(){  $("button").click(function(){  alert($(this).html());  $(this).hide();  $("p").hide();});});</script></head><body><button type="button">Click me</button><p>coding1</p><p>coding2</p><p>coding3</p></body></html>


使用$(this)就可以获得当前元素,上面的文字就是$(this).html()就可以了。

0 0
原创粉丝点击