Calling Javascript from a html form

后端 未结 6 418
眼角桃花
眼角桃花 2021-01-30 06:18

I am basing my question and example on Jason\'s answer in this question

I am trying to avoid using an eventListener, and just to call handleClick

6条回答
  •  礼貌的吻别
    2021-01-30 07:03

    You can either use javascript url form with

    Or use onSubmit event handler

    
    

    In the later form, if you return false from the handleClick it will prevent the normal submision procedure. Return true if you want the browser to follow normal submision procedure.

    Your onSubmit event handler in the button also fails because of the Javascript: part

    EDIT: I just tried this code and it works:

    
      
        
      
    
    
        
          
        
    
    
    

提交回复
热议问题