<button> versus <input type=“image”>

前端 未结 3 855
耶瑟儿~
耶瑟儿~ 2021-01-04 10:18

This is for an \"Add to basket\" control for which one of my colleagues has designed a nice graphic. Obviously it should generate a post request, which a simple hyperlink i

3条回答
  •  Happy的楠姐
    2021-01-04 11:00

    From MDN:

    When you submit a form using a button created with , two extra data points are submitted to the server automatically by the browser — x and y.

    So one difference is that the input[type=image] transmits the coordinates of the pixel you clicked. It is 2019 and button is well supported so personally I use it unless I really need x, y - lets say, if the image is a map and I want to know where the user clicked in the map.

提交回复
热议问题