0
只是在這裏爲jQuery選擇器的一點幫助..問題是當我點擊(「.x」),(「.bigCon」)也會觸發..我只是希望只有( 「.bigcon 」)將擁有的onclick則警告(「 黑」)......很抱歉有點混亂事件..:djquery選擇器:父問題
<html>
<head>
<title></title>
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script>
$(document).ready(function(){
$(".x").click(function(){
$(".evClick").removeClass("evClick").addClass("sample");
$(this).addClass("evClick");
}).mouseover(function(){
$(this).toggleClass("evHover");
}).mouseout(function(){
$(this).toggleClass("evHover");
});
$(".bigCon").click(function(){
alert("black");
});
});
</script>
<style>
.x {
width:100px;
height:100px;
margin:10px;
}
.bigCon {
background:black;
width:240px;
height:540px;
}
.sample {background:red;}
.evHover {background:green;}
.evClick {background:yellow;}
</style>
</head>
<body>
<div class="bigCon">
<div class="sample x"></div>
<div class="sample x"></div>
<div class="sample x"></div>
<div class="sample x"></div>
<div class="sample x"></div>
</div>
</body>
</html>
謝謝先生.. – 2010-12-20 07:24:54