Asp,Php,Jssdk,mysql,mssql,微信公众号开发,小程序开发-学习笔记 收集日常学习笔记和重点,交流QQ:79657181,手机/微信:18611436777

jquery_遍历数组下级元素

<style type="text/css">

#one{ width:1000px; height:800px; border:1px solid #0000FF; margin:30px}

#two{ width:800px; height:600px; border:1px solid #FF0000; margin:30px}

#three{ width:600px; height:400px; border:1px solid #FF00FF; margin:30px}

#four{ width:400px; height:200px; border:1px solid #3366FF; margin:30px}

#five{ width:200px; height:100px; border:1px solid #660066; margin:30px; }

</style>

</head>


<body>

<div id="one">

<div id="two">

<div id="three">

<div id="four">

<div id="five">cs</div>

</div>

</div>

</div>

</div>

<input type="button" id="xj" value="加背景测试" />

<input type="button" id="rxj" value="one下的所有框加背景" />

<input type="button" id="txj" value="one下的某个元素加背景" />


<script type="text/javascript">

$(document).ready(function(){//页面加载完在执行jq

$("#xj").click(function(){

$("#five").css({"background":"#FF0000"})

});

$("#rxj").click(function(){

$("#one").find("*").css({"background":"blue"});//find加上*号是指某个id或是元素下的所有元素选定

});

$("#txj").click(function(){

$("#one").find("#four").css({"background":"red"})//find下的指定元素加上背景

});

});

</script>


2018年10月21日 | 发布:anco | 分类:jquery | 评论:0