[英]JQuery: link in dropdown is not clickable
我的問題是下拉列表中的Wikipedia-Link不可點擊。 我已經嘗試用stopPropagation()來解決問題; 但這不起作用。
HTML:
<section id="help_advanced_rules_section">
<div class="bar_bottom_left"></div>
<div class="bar_mid" id="bar_mid_7"><h3>8. Rules</h3></div>
<div class="bar_bottom_right"></div>
<div class="bar_ear" id="bar_ear_7"></div>
<article id="article_7">
<div class="image_section">
<img src="images/help_1.png" id="image_7">
</div>
<div class="text_section">
<p>Look up the rules on Wikipedia.</p>
<p><a href="http://google.de"><img src="images/wikipedia_en.png" id="wikipedia"></a></p>
</div>
</article>
</section>
JQUERY:
<script>
function closeArticle(article) {
article.css("paddingTop", "0px");
article.css("paddingBottom", "0px");
article.animate({maxHeight: "1.2em"}, 200, function () {
article.children().css("display", "none");
});
article.removeClass('expanded');
}
function openArticle(article) {
closeAllArticle();
article.children().css("display", "block");
article.css("paddingTop", "1em");
article.css("paddingBottom", "0.5em");
article.animate({maxHeight: "2000px"}, 250, function () {
article.animate({maxHeight: article.height() + "px"}, 0); //maxheight wird auf die höhe gesetzt die das element nach dem ausfahren hat um die animation danach zu verkürzen
article.addClass('expanded');
$('html, body').animate({scrollTop: article.offset().top - 40
}, 100);
});
}
function closeAllArticle() {
$('.expanded').each(function(){
closeArticle($(this));
});
}
function openCloseArticle(article) {
if(article.hasClass('expanded'))
{
closeArticle(article);
}
else
{
openArticle(article);
}
}
$( document ).ready(function() {
var toggle = function(id, element_name) {
//Get ArticleID
var toRemove = element_name;
var number = id.replace(toRemove, '');
var articleID = "#article_"+number;
var article = $(articleID);
openCloseArticle(article)
};
$(".bar_mid").click ( function() {
toggle($(this).attr("id"), "bar_mid_");
});
$(".bar_ear").click ( function() {
toggle($(this).attr("id"), "bar_ear_");
});
});
</script>
我使用stopPropagation()嘗試了多種方法; 但是沒有用。 也許我只是不了解它是如何工作的,或者我需要以另一種方式解決我的問題。
那么,使Wikipedia-Button可點擊的最佳方法是什么?
問題出在article
css規則中的z-index:-1
中。 article塊實際上位於section塊的后面。 通過右鍵單擊chrome中的鏈接並選擇“檢查元素”,可以發現這是問題所在。 它將使用選定的鼠標光標下方的最高元素打開開發人員工具。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.