我使用下面的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