我試圖添加一個小的「觸發器框」,點擊後會打開。它曾經工作過一段時間,但我不確定現在有什麼錯誤。無法獲取觸發器框
我學到了一點HTML和CSS,所以我理解這些部分發生了什麼,但我幾乎不知道Javascript。所以腳本選擇器中的所有內容對我而言都是新的;有人在線提供了它,我試圖理解它。閱讀語法,我想我知道發生了什麼,但我仍然不知道問題到底是什麼。
這是我的代碼。是的,它全部在1個HTML文件中,因爲這僅僅是1頁。
<!DOCTYPE html>
<html>
<head>
<title> This is the Title </title>
<style type="text/css">
html, body { color:#666; font:"Times New Roman", Times, serif; }
h1 { font-size:36px; color:#333; margin:0 0 15px 0; padding:0 0 15px 0; border-bottom: solid 1px #e1e1e1; }
.awesomeBox { border:solid 1px #cacaca; box-shadow: 0 0 3px #bbb; padding:15px; margin:20px; width:400px; }
.trigger { cursor:pointer; }
/* this is all you need to make the hidden box hidden :) */
.hiddenBox { display:none; }
/* we put a little style to the trigger */
.box { position:relative; }
.box .trigger { font-size:12px; background:#cacaca; padding:5px 10px; color:#fff; text-decoration:none; position:absolute; bottom:-42px; right:0; }
.box .hiddenBox { background:#f9f9f9; color:#000; padding:10px; margin:10px; }
</style>
<script src = "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(function() {
$(".trigger").on("click", function() {
$(".hiddenBox").toggle();
});
});
</script>
</head>
<body>
<div class="awesomeBox">
<h1 class="trigger">Le awesome Page</h1>
<div class="box">The area where you could type a lot of text but also want to hide some text<br>
<p>So, user will press the read more button.</p> <a href="#" class="trigger">Read more »</a>
<div class="hiddenBox">
<p>A lot of text in this hidden box and ...
a lot
alot more
fsdfsd
</p>
<img src="https://www.google.com/images/srpr/logo4w.png" width="100%" />
</div>
</div>
</div>
</body>
</html>
作品之前,我說:http://jsfiddle.net/j08691/FpL2H/ – j08691 2013-04-03 21:17:58
你從哪裏複製此? – Daedalus 2013-04-03 21:34:04