1
我想將一個錨標籤放置在一個文檔元素中,該元素具有附加的jQuery .slideToggle函數。jQuery .slideToggle用法
這是HTML:
<section id="recent_articles">
<article>
<img src="images/image1.jpg">
<h1>Insert title here</h1>
<p>Insert text here followed by an anchor tag<a href=#>Read More</a></p>
</article>
</section>
The jQuery looks like this:
$("#recent_articles > article").click(function(e) {
$(this).children("p").slideToggle(1000);
$(this).toggleClass("open");
});
據我瞭解,jQuery是「激活」只要單擊文章元素(包括圖像元件)和段落滑動向下和向上的指示。
但這意味着錨元素無法訪問,因爲它響應jQuery而不是href屬性。
使用jQuery,我將如何訪問anchor元素,以便它使用默認鏈接行爲進行響應,而不是使用.slideToggle函數。
我非常非常新的使用jQuery,所以任何意見將不勝感激。
所以你基本上要放錨裏面的鏈接,對不對?它應該導航到同一頁面內的某些內容,但您希望它阻止觸發動畫,對不對? – 2014-12-07 23:36:07
正確,但鏈接錨點應轉到新頁面。目前,單擊段落內的鏈接只會觸發.slideToggle函數。 – 2014-12-07 23:44:31
奇怪的是,它應該在任何情況下導航......除非你在某處使用'return false'或'event.preventDefalt()'... – 2014-12-07 23:46:25