簡體   English   中英

顯示一個 <div> 當用戶單擊帶有href“#”的鏈接時

[英]Show a <div> when the user clicks a link with href “#”

每次用戶單擊鏈接時,腳本都應檢查文檔 如果href ,則腳本應顯示帶有ID 視頻的div。

(我需要將此特定作品作為圖像庫的補丁。我無法為畫廊中不同圖像的特定內容使用title屬性。)

偽代碼:

If user clicks <a> with href="#"
Show div #video
$('a[href="#"]').click(function(){
    $("#video").show();
});
$('a[href="#"]').click(function(){
    $("#videoDiv").show();
});
$('a[href="#"]')

然后做你的節目div!

您可以使用$('a[href=#]').click(myFunction);

嘗試這個:

$('a[href$=#]').click(function(e){
    $("#video").show();
    e.preventDefault();
    return false;
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM