问题
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