+ Reply to Thread
Results 1 to 2 of 2

Thread: trigger javascript on anchor click

  1. #1

    trigger javascript on anchor click

    I have a situation where I am dynamically adding some content to popup box (which is a div) on my page from c#
    HtmlGenericControl content = new HtmlGenericControl();
    content.InnerHtml = "<a id='close' href='' onclick='action()'>close</a><span>Some text here</span>";
    divcontrl.Attributes.Add("class", "myclass");
    javscript method:function action() {$('.myclass').hide();}
    If I keep href='' on anchor it's closing the window but reloading the page, if I remove it not closing the window , i hope you guys help me with that

  2. #2
    Junior Member
    Join Date
    Jan 2012
    You should be doing that :
    href="javascript:void(0);" onclick='return action()'
    And add return to the js function .
    function action() {
        return false;

+ Reply to Thread

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts