How to call JavaScript function instead of href in HTML

前端 未结 7 1277
执念已碎
执念已碎 2020-12-12 20:18

I have some mockup in HTML

\"next

        
7条回答
  •  北海茫月
    2020-12-12 20:35

    Your should also separate the javascript from the HTML.
    HTML:

    next page
    

    javascript:

    myLink = document.getElementById('function-click');
    myLink.onclick = ShowOld(2367,146986,2);
    

    Just make sure the last line in the ShowOld function is:

    return false;
    

    as this will stop the link from opening in the browser.

提交回复
热议问题