Home > Web Front-end > JS Tutorial > jQuery获取当前点击的对象元素(实现代码)_jquery

jQuery获取当前点击的对象元素(实现代码)_jquery

WBOY
Release: 2016-05-23 13:15:55
Original
1496 people have browsed it

jQuery获取当前点击的对象元素(实现代码)

<script type="text/javascript" src="script/jquery-1.8.3.js"></script>
</head>
<body>
    <p>段落1</p>
    <p>段落2</p>
    <p>段落3</p>
    <p>段落4</p>
    <p>段落5</p> 
  <script type="text/javascript">
  //获取当前点击的对象
  $('p').click(
    function(){
      //this表示当前被点击元素,但是此时我们当做dom对象
      //window.alert(this.innerHTML);
      //$(this) 表示当前被点击元素,但是此时我们当做jquery对象
      window.alert($(this).html());
      //window.alert('ok');
    });
</script> 
</body> 
Copy after login

以上这篇jQuery获取当前点击的对象元素(实现代码)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

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