event.preventDefault() on first click then remove

后端 未结 5 1469
余生分开走
余生分开走 2021-02-03 13:35

I have the default anchor disabled if it has a class subnav as shown in this fiddle.

I only want this disabled for the first click then I want the normal anchor function

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-03 14:02

    this will work for you

    $("#elementid").bind("click", function( event ) {
      alert("This will be displayed only once.");
      event.preventDefault(); 
      $(this).unbind( event );
    });
    

提交回复
热议问题