我試圖設置一個colorbox(當你點擊'註冊我'按鈕),但它似乎並沒有啓動。無法找到任何JavaScript錯誤或控制檯錯誤,只是似乎沒有觸發。ColorBox未加載 - 所有JS正在通過正確
我已經鏈接了樣式表,JS文件幷包含了頭文件,它們都打開並正確調用到頁面中。
<link rel="stylesheet" href="css/colorbox.css" />
<script src="js/jquery.colorbox.js"></script>
<script>
$(document).ready(function(){
//Examples of how to assign the ColorBox event to elements
$(".inline").colorbox({inline:true, width:"50%"});
$(".callbacks").colorbox({
onOpen:function(){ alert('onOpen: colorbox is about to open'); },
onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
});
//Example of preserving a JavaScript event for inline calls.
$("#click").click(function(){
$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
return false;
});
});
</script>
我創建了內聯內容div(隱藏)並正確鏈接了按鈕。
<span class="btn"><a href="#inline_content">Sign Me Up!</a></span>
這裏是內嵌的內容:
<div style='display:none'>
<div id='inline_content' style='padding:10px; background:#fff;'>
<p><strong>This content comes from a hidden element on this page.</strong></p>
<p>The inline option preserves bound JavaScript events and changes, and it puts the content back where it came from when it is closed.</p>
</div>
</div>
我已經改變了我的網站,你給我的代碼,但它仍然沒有工作。代碼是從colorbox例子中獲得的,所以我認爲這是正確的,並且沿線必須有一個斷開的鏈接?您可以在這裏再次查看更新的版本:http://www.rubytuesdaycreative.co.uk/testsite/ – Francesca
Francesca,它看起來像你有無效的jQuery。有太多的右括號。請在上面查看,因爲我更新了我的答案,以使您更輕鬆。刪除之間的所有代碼,並將我爲您提供的代碼段放在那裏,並將class =「inline」添加到鏈接:) –
完美謝謝! – Francesca