我有一個div(A),並在另一個div(B)內,然後我有我的鏈接。我想要發生的是,當我們點擊A時,div(B)中的鏈接起作用。jQuery鏈接工程時點擊父母的div
我成功由一個家長這樣做,但不是2 ...
$(".block").mouseover(function() {
if ($(".block .button").length) {
$(this).css("cursor", "pointer").find(".invisible.button").css("text-decoration", "none");
}
}).mouseout(function(e) {
e.preventDefault();
e.stopPropagation();
$(this).find(".invisible.button").css("text-decoration", "none");
}).click(function(e) {
document.location.href = $(this).find(".invisible.button").attr("href");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div class="wrap">
<div class="wrap-in block">
<p>content</p>
<a class="invisible button" href="mylink"> go</a>
</div>
</div>
我找不到讓我的鏈接方式工作的」單擊時。包裹」分區,如果有人可以幫助:)
一個信息 如果‘包裝’有沒有聯繫,我還有一個類:
的一點是,如果我只是做:
$(".wrap").mouseover(function() {
if ($(".block .button").length) {
$(this).css("cursor", "pointer").find(".invisible.button").css("text-decoration", "none");
}
}).mouseout(function(e) {
e.preventDefault();
e.stopPropagation();
$(this).find(".invisible.button").css("text-decoration", "none");
}).click(function(e) {
document.location.href = $(this).find(".invisible.button").attr("href");
});
它的工作原理,但它工作在DIV 沒有 anylink太...
和我的代碼,中止「nolink」
$('.nolink').on('click', function(e){
e.preventDefault();
e.stopImmediatePropagation();
});
不清楚你問:( –
點擊'#wrap'觸發點擊'.invisible' ?鏈接,然後 – Drakes
'$( 「#換行」)上( 「點擊」,功能(E){$( 「a.invisible」)觸發( 「點擊」);});' – Drakes