Simulating click event on input - JavaScript

后端 未结 3 729
温柔的废话
温柔的废话 2021-01-21 01:42

I\'m trying to simulate a click on an input tag, through the click on an anchor tag, this way I can hide the input and wrap an image inside the anchor tag.

3条回答
  •  清酒与你
    2021-01-21 02:19

    You don't need JavaScript at all to solve this problem.

    Just make the input invisible by setting its opacity:0 and position both elements absolutely within a common parent element, then make sure the input is on the top layer and is the same size as the image behind it.

    #user_avatar { opacity:0; position:absolute; z-index:9; width:320px; height:240px; }
    img { position:absolute; z-index:-1; }

提交回复
热议问题