jQuery中prevUntil()方法用法实例(2)


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="https://www.jb51.net/" />
<title>脚本之家</title>
<style type="text/css">
.father {
        height:200px;
        width:200px;
        border:1px solid blue;
}
</style>
<script type="text/javascript" src="https://www.jb51.net/mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $(".father div").prevUntil(document.getElementById("firstp"),"span").css("color","blue")
    })
</script>
</head>
<body>
<div>
  <p>我是p元素</p>
  <span>我是span元素</span>
  <p>我是p元素</p>
  <div>我是div元素</div>
</div>
</body>
</html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgxgds.html