html button v.s. html submit?

后端 未结 6 1360
南旧
南旧 2020-12-09 19:14

I have an input text box and a search submit button, and when user clicks the Search submit button, I want to redirect user to url http://testsearch/results.aspx?k=<

6条回答
  •  旧巷少年郎
    2020-12-09 19:28

    You can even use the submit button this way:

     
    

    Semantically submit button is used to submit forms not redirect pages. You should use normal button type for this. However as i showed you can use the submit button too but that is not semantic i think.

    The below line prevents the form from being submitted.

    return false;
    

    That is what you are missing in your code :)

    Thanks

提交回复
热议问题