最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Show a <div> when the user clicks a link with href "#" - Stack Overflow

programmeradmin1浏览0评论

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

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
Share Improve this question edited Dec 22, 2012 at 23:53 mjk 2,4534 gold badges34 silver badges33 bronze badges asked Nov 26, 2010 at 10:44 TomkayTomkay 5,16021 gold badges65 silver badges94 bronze badges 1
  • No. - I mean href="#" nothing else^^ – Tomkay Commented Nov 26, 2010 at 10:49
Add a ment  | 

5 Answers 5

Reset to default 3
$('a[href="#"]').click(function(){
    $("#video").show();
});
$('a[href="#"]').click(function(){
    $("#videoDiv").show();
});
$('a[href="#"]')

Then do your show div!

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

Try this:

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

评论列表(0)

  1. 暂无评论