<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题页</title>
<script src="jquery-1.10.2.js" type="text/javascript"></script>
<script type="text/javascript">
//链式编程
$(function(){
$('div').click(function(){
$(this).css("background","red").siblings("div").css("background","white");
});
});
</script>
</head>
<body>
<input type="button" id="btn"/>
<div class="warning">警告1!</div>
<div class="warning">警告2!</div>
<p>P1</p>
<p>P2</p>
<div class="warning">警告3!</div>
<div class="warning">警告4!</div>
</body>
</html>
Jquery系列-Jquery链式编程
最新推荐文章于 2024-04-06 22:50:04 发布
本文通过一个简单的示例展示了如何使用jQuery实现链式编程。当点击带有'warning'类的div元素时,该div背景变为红色,而其他兄弟div元素背景变为白色。
210

被折叠的 条评论
为什么被折叠?



