0
<!DOCTYPE html>
<html>
<head>
  <style>
p { margin:-3px 0px 0px 3px;
background:#212121;
width:175px;
padding:10px;
color:#fff;
font-weight:500;
font-size:14px; }
</style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
  <button>Toggle 'em</button>

<p>I figured out how to get the toggle to look and work up to this point, but I can't seem to get this content box to appear ONLY AFTER the button is clicked upon NOT before. And, when the visitor doesn't want to see the content anymore, s/he would have to click on the button (toggling). If you happen to know how to incorporate a delayed auto close on this toggle, please do tell (if not, no biggie--not my main focus). Thanks! </p>
    <script>
$("button").click(function () {
$("p").toggle("fast");
});    
</script>

</body>
</html>

我对 JQuery 不太了解,但我使用了这个网站http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_toggle并弄清楚了如何让切换器看起来和工作到这一点,但我似乎无法让这个内容框出现在按钮被点击之后而不是之前。而且,当访问者不想再看到内容时,他/她必须点击按钮(切换)。如果您碰巧知道如何在此切换中加入延迟自动关闭,请务必告诉(如果没有,没什么大不了的——不是我的主要关注点)。谢谢!

4

2 回答 2

0

只需添加:

显示:无;

到 CSS

于 2012-12-16T04:06:34.430 回答
0

改用这个!

$(document).ready( function() {
$("p").hide();
$("button").click(function () {
$("p").toggle("fast");
});
});

http://jsfiddle.net/N6NJR/

于 2012-12-16T04:07:19.817 回答