我想通过单击父div(1或2或3)中的(p)标签来隐藏p,p将消失,div div(11或12或13)p将按照消失的p出现那个部门。
我如何在不使用 ID 名称的情况下做到这一点?
<!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>