jQuery中nextUntil()方法用法实例教程
本文实例讲述了jquery中nextuntil()方法用法。分享给大家供大家参考。具体分析如下:
此函数查找指定元素之后所有的同辈元素,直到遇到匹配的那个元素为止,但不包括此匹配的元素。
语法结构一:
代码如下:
$(selector).closest(expr, filter)
参数列表:
实例代码:
实例一:
代码如下:
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="author" content="https://www.cnblogs.com/" />
<title>博客园</title>
<script type="text/javascript" src="mytest/jquery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("li").eq(0).nextuntil(".jq").css("color","blue")
})
</script>
</head>
<body>
<p>
<ul>
<li>html专区</li>
<li class="js">javascript专区</li>
<li>div+css专区</li>
<li class="jq">jquery专区</li>
<li>asp专区</li>
<li>jsp专区</li>
</ul>
</p>
</body>
</html>
实例二:
代码如下:
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="author" content="https://www.cnblogs.com/" />
<title>博客园</title>
<script type="text/javascript" src="mytest/jquery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("li").eq(0).nextuntil(".jq",".js").css("color","blue")
})
</script>
</head>
<body>
<p>
<ul>gt;
<li>html专区</li>
<li class="js">javascript专区</li>
<li>div+css专区</li>
<li class="jq">jquery专区</li>
<li>asp专区</li>
<li>jsp专区</li>
</ul>
</p>
</body>
</html>
语法结构二:
代码如下:
$(selector).closest(element, filter)
参数列表:
实例代码:
实例一:
代码如下:
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="author" content="https://www.cnblogs.com/" />
<title>博客园</title>
<script type="text/javascript" src="mytest/jquery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("li").eq(0).nextuntil(document.getelementbyid("jq")).css("color","blue")
})
</script>
</head>
<body>
<p>
<ul>
<li>html专区</li>
<li class="js">javascript专区</li>
<li>div+css专区</li>
<li id="jq">jquery专区</li>
<li>asp专区</li>
<li>jsp专区</li>
</ul>
</p>
</body>
</html>
实例二:
代码如下:
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="author" content="https://www.cnblogs.com/" />
<title>博客园</title>
<script type="text/javascript" src="mytest/jquery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("li").eq(0).nextuntil(document.getelementbyid("jq"),".js").css("color","blue")
})
</script>
</head>
<body>
<p>
<ul>
<li>html专区</li>
<li class="js">javascript专区</li>
<li>div+css专区</li>
<li id="jq">jquery专区</li>
<li>asp专区</li>
<li>jsp专区</li>
</ul>
</p>
</body>
</html>