<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>控制DIV的选取</title>
</head>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<style type="text/css">
div[id^="div"]
{
width:200px;
height:500px;
border:1px solid black;
background-color:#FC0;
float:left;
margin-left:5px;

}
</style> 

<script type="text/javascript">
 $(function(){
$("div[id^='div']").mouseover(function(){
$(this).css("background-color","red");
});
$("div[id^='div']").mouseout(function(){
$(this).css("background-color","#FC0");
});
}); 

/* $(document).ready(function(e){
$("div[id^='div']").hover(function(e){
$(this).css("background-color","black");
},function(e){
$(this).css("background-color","#FC0");
});
}); */
</script>

<body>
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
<div id="div4"></div>
</body>

</html>

控制DIV的选取

相关文章:

  • 2021-11-13
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
猜你喜欢
  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案