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

不羁的心 提交于 2020-01-06 14:46:29

问题


The script should check the document every time the user clicks a link. If the href is #, the script should show a div with the ID video.

(I need this specific piece as a patch for an image gallery. I'm having trouble using the title attribute for specific content for different images in the gallery.)

Pseudo code:

If user clicks <a> with href="#"
Show div #video

回答1:


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



回答2:


$('a[href="#"]').click(function(){
    $("#videoDiv").show();
});



回答3:


$('a[href="#"]')

Then do your show div!




回答4:


you can use $('a[href=#]').click(myFunction);




回答5:


Try this:

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


来源:https://stackoverflow.com/questions/4284558/show-a-div-when-the-user-clicks-a-link-with-href

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!