我有兩個div。當用戶點擊div'body'div上的任何位置時,點擊第一個點擊jquery show。簡單的jquery忽略顯示/隱藏div當用戶點擊鏈接
我的問題是,當用戶點擊'body'div中的鏈接時,節目會在鏈接加載之前執行。它會讓那些認爲自己錯過了最後一頁的用戶感到困惑。 是否可以爲「body」div中的鏈接創建一個簡單的例外?
<div>
<div class="body">
<p>Some really good links</p>
o Example Org: <a href="http://example.org">example.org</a><br>
o Example Dotcom: <a href="http://example.com">example.com</a>
</div>
<div class="toggle" style="display: none;">
<p>Some really detailed information here.</p>
</div>
</div>
我的JavaScript像這樣:
<script>
$(document).ready(function() {
bindToggle;
});
function bindToggle() {
$(".toggle").hide();
$(".body").click(function(event) {
el = $(this).next();
if (el.is(":visible")) {
el.hide('fast');
} else {
el.show('fast');
}
});
};
</script>
這裏是一個演示:http://jsfiddle.net/esJsP/3/
只要使用'$(本)。接下來()切換( '快');' – Bergi