gpt4 book ai didi

jquery - 在jquery中隐藏段落元素

转载 作者:行者123 更新时间:2023-12-01 06:26:27 25 4
gpt4 key购买 nike

我需要在查询中隐藏一个元素段落,但我希望该元素段落被隐藏并保留其位置,下面的按钮不会取代段落

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#hide").click(function(){
$("p").hide();
});
$("#show").click(function(){
$("p").show();
});
});
</script>
</head>
<body>

<p>If you click on the "Hide" button, I will disappear.</p>

<button id="hide">Hide</button>
<button id="show">Show</button>

</body>
</html>

最佳答案

试试这个

$(document).ready(function(){
$("#hide").click(function(){
$("p").css('visibility', 'hidden');
});
$("#show").click(function(){
$("p").css('visibility', 'visible');
});
});

关于jquery - 在jquery中隐藏段落元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29611045/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com