Returning false on link click jquery

后端 未结 4 1552
孤街浪徒
孤街浪徒 2021-01-24 22:33

I wish to have a link which opens popup when clicked however I wish it to open a page in a new window if the user doesn\'t have JS enabled.

The following doesn\'t seem t

4条回答
  •  故里飘歌
    2021-01-24 22:57

    In order to make this functionality more browser-compatible, you need to pass the event object to the click handler, then call e.preventDefault();.

    example:

    $( '#button' ).click( function( e ) {
        //... your code...
    
        e.preventDefault();
        return false;
    } );
    

提交回复
热议问题