Jquery 将子div11显示在与另一个子标记p相同的父div中
我想通过单击父div1或2或3中的p标记来隐藏p。p将消失,div div11或12或13 p将与该分区中消失的p一致出现 在不使用ID名称的情况下,我如何做到这一点Jquery 将子div11显示在与另一个子标记p相同的父div中,jquery,hide,parent,show,Jquery,Hide,Parent,Show,我想通过单击父div1或2或3中的p标记来隐藏p。p将消失,div div11或12或13 p将与该分区中消失的p一致出现 在不使用ID名称的情况下,我如何做到这一点 <!DOCTYPE html> <html> <head> <script src="jquery.js"></script> <script> $(document).ready(function(){ $("div p").click(functi
<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$("div p").click(function(){
$(this).hide();
//What do I need to put here?? to show the <p> in the <div id="11 or 12 or 13"> according to the <p> that is clicked
});
});
</script>
</head>
<body>
<div class = "" id="1">
<p>If you click on me, I will disappear.</p> // BY CLICKING THIS P HIDE IT THEN
<div id="11" style="display:none;">
<p>You have clicked me<p> // THEN SHOW THIS P
</div>
</div>
<span> HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH </span>
<div id="2">
<p>Click me away!</p>
<div id="22" style="display:none;">
<p>You have clicked me too!<p>
</div>
</div>
<span> HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH </span>
<div id="3">
<p>Click me too!</p>
<div id="33" style="display:none;">
<p>You have clicked me three!<p>
</div>
</div>
<span> HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH </span>
</body>
</html>
我想您需要这样的东西,请参见jquery文档中的或
$("div p").click(function(){
$(this).hide().next().show();
});
我想您需要这样的东西,请参见jquery文档中的或
$("div p").click(function(){
$(this).hide().next().show();
});
为了制作div,在p show旁边可以使用$this.next.show
为了制作div,在p show旁边可以使用$this.next.show
$this.next.show对于给定的html应该足够了$this.next.show对于给定的html应该足够了。这就成功了:谢谢沃尔夫。这就成功了: