注意index是从0开始的,A function used as a test for each element in the set. this is the current DOM element.0-based

 

 

<!DOCTYPE html>
<html>
<head>
<style>
div
{ width:60px; height:60px; margin:5px; float:left;
border
:3px white solid; }
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>

<div id="first"></div>
<div id="second"></div>
<div id="third"></div>

<div id="fourth"></div>
<div id="fifth"></div>
<div id="sixth"></div>
<script>
$(
"div").css("background", "#b4b0da")
.filter(
function (index) {
return index == 1 || $(this).attr("id") == "fourth";
})
.css(
"border", "3px double red"); 、、

change the color of all divs; then add a border to the second one (index == 1) and the div with an id of "fourth."



</script>

</body>
</html>



相关文章:

  • 2021-11-21
  • 2022-12-23
  • 2021-05-13
  • 2021-12-10
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2021-04-21
  • 2021-11-30
  • 2022-12-23
相关资源
相似解决方案