gpt4 book ai didi

javascript - 为什么 jQuery show() 不工作?

转载 作者:太空狗 更新时间:2023-10-29 14:51:18 25 4
gpt4 key购买 nike

我正在使用 jQuery 通过 hide() 隐藏一个 div。

然后当一个链接被点击时它会显示div,但由于某些原因它不会停留。它会显示一毫秒然后消失。

HTML

<div id="introContent">
<h1 id="introText">Welcome</h1>
<p id="introParagraph">I create <strong>Responsive</strong>, <strong>Interactive</strong>, <strong>Beautiful</strong> Mobile ready Websites.
Every Website is created from scratch for each client so no Two Projects are alike.
Please read more about my Company and our work.
"High Quality Work at Affordable Prices"
</p>
</div>

jQuery

$(function() {
$("#introContent").hide();
$("#intro").click(function () { //$(#intro) is a link in my nav bar
$("#introContent").show();
});
});

最佳答案

阻止浏览器执行您正在单击的元素的默认操作。取消点击

$(function() {
$("#introContent").hide();
$("#intro").click(function (evt) {
evt.preventDefault();
$("#introContent").show();
});
});

关于javascript - 为什么 jQuery show() 不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27972803/

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