jquery next()方法使用程式碼例項

admin發表於2017-04-05

本章節分享一段程式碼例項,它簡單演示了next()方法的使用。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.51texiao.cn/" />
<title>螞蟻部落</title>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<script type="text/javascript"> 
$(document).ready(function() {
  $("span").click(function(){
    alert($("p").next(".selected").html());
  })
});
</script>
</head>
<body>
<p>螞蟻部落</p>
<p class="selected">url地址是softwhy.com</p>
<div>
  <span>點選測試</span>
</div>
</body> 
</html>

關於next()方法的功能介紹可以參閱jQuery next()方法一章節。

相關文章