我已經在按鈕上添加了一個mouseover事件。在該事件中,我正在呼叫錨上的mouseover事件。然而,該錨點的mouseover沒有被正確觸發。我無法看到左下角的URL預覽,就像我把滑鼠懸停在錨元素上時看到的那樣。我怎樣才能正確地觸發錨點上的滑鼠移動呢?
$(document)。 ready(function() {
$("button.pdfbutton"/span>).mouseover(function(e) {
$("#anchorelem").show() 。
$("#anchorelem").mouseover() 。
});
});
<script src="https://cdnjs. cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>/span>
<button class="pdfbutton"/span>> PDF</button>
<a href="https://google. com" id="anchorelem" style="display: none;">一些文本</a>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
uj5u.com熱心網友回復:
瀏覽器左下角的<a>元素的URL預覽(據我所知)不是由JS事件觸發的(這意味著你不能通過呼叫mouseover()觸發它)。它只是瀏覽器的原生功能。如果你想顯示預覽,我建議采用以下方式之一:
<a>元素,并將其風格化為普通按鈕的樣子。然后,當有人將滑鼠懸停在它上面時,他們將看到它所指向的鏈接。
uj5u.com熱心網友回復:
。$(document)。 ready(function() {
$("button.pdfbutton"/span>).mouseover(function(e) {
$("#anchorelem").show() 。
$("#anchorelem").mouseover() 。
$("#txt_lnk").bind('click', false) 。
});
});
<script src="https://cdnjs. cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>/span>
<button class="pdfbutton">/span>
<a id="txt_lnk"/span> href="http: //text-to-show" style="text-decoration:none; color:black;">PDF</a>
</button>/span>
<a href="http://google. com" id="anchorelem" style="display: none;">一些文本</a>
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/306718.html
標籤:
上一篇:如何在沒有jQuery或ID的情況下找到HTML字串中的某些元素
下一篇:從虛擬類鑄造派生模板類
