我使用下面的HTML代碼:選擇元素的所有子元素並使用jQuery淡出它們?
<!DOCTYPE html>
<html>
<head>
<title>Project Quiz</title>
<link rel="stylesheet" type="text/css" href="z/baseCss.CSS">
<script src="/jquery-1.9.1.min.js"></script>
<script src="/baseJS.js"></script>
</head>
<body>
<div id=header></div>
<div id=contain>
<h1>Welcome to my web application</br>
Please enter your name, click 'continue' and have fun</h1>
<form>
<input type="text" id="name" value="John Doe"/>
</form>
<div class="awesome">Continue</div><br/>
</div>
<div id=footer></div>
</body>
</html>
和jQuery的代碼:
$(document).ready(function(){
$("input")
.focus(function(){
$(this).css('outline-color','#559FFF');
$(this).blur(function(){
$(this).css("outline-color","#FF0000");
});
});
$("input").click(function(){
var value = $(this).val(function(){
$(this).html("");
});
});
$(".awesome").click(function(){
b._slide(1000);
});
var b = $("div:nth-child(2)");
alert(b);
});
我的問題是,我無法弄清楚如何選擇的<div id="contain">
,只是所有的孩子讓他們淡出,當我點擊我的div按鈕,這是與「真棒」類的人。
這是我到目前爲止已經試過:這裏
$(".contain").each(function(){
$(this).fadeOut(1000);
});
but it didnt work also i tried:
$(".contain").children(function(){
$(this).fadeOut(1000);
});
相同的結果。
我在做什麼錯?我只需要fadeOut
<div id="contain">
的內容,並保持其他所有內容相同。
感謝我unerstand它!非常感謝! – 2013-04-04 23:01:45
我很高興我的幫助,祝你好運 שמזשעזרתי,בהצלחה:) 如果這個答案解決了你的問題,請考慮接受它。 – 2013-04-04 23:03:40