What is href=[removed];

前端 未结 8 911
天命终不由人
天命终不由人 2020-12-31 18:42

in a code which i am goin through there is a link has href=javascript:; in code.when it is clicked it opens a lightbox to show some msg with close button.how is it done.I th

相关标签:
8条回答
  • 2020-12-31 19:28

    href="javascript:somefunction();" is just a way to point to a function of some javascript code.

    You can also do: href="#" onclick="somefunction();return false;"

    Nothing really dojo about it. All it does is call the function or javascript code. It just tells the element to use javascript.

    or href="javascript:void(0);" onclick="somefunction();" as stated already.

    0 讨论(0)
  • 2020-12-31 19:28
    <a href="javascript:void(0)" onClick="callFunction();">
    

    Call callFunction() method onClick

    this can also be used as foollows

    <a href="javascript:callFunction();">
    
    
    <a href="#" onClick="callFunction();">
    

    this also call javascript callFunction() method but it adds # in your URL to Avoid this Use

    <a href="javascript:void(0)" onClick="callFunction();">
    
    0 讨论(0)
提交回复
热议问题