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 に答える