a tag as a submit button?

前端 未结 6 1117
执笔经年
执笔经年 2020-12-24 01:32

Hi I am trying to get \"a\" tag as a submit button. I found a code somewhere in the web. But it didn\'t work.



        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-24 01:43

    Give the form an id, and then:

    document.getElementById("yourFormId").submit();

    Best practice would probably be to give your link an id too, and get rid of the event handler:

    document.getElementById("yourLinkId").onclick = function() {
        document.getElementById("yourFormId").submit();
    }
    

提交回复
热议问题