After the html element sets position:absolute absolute positioning, the onclick click event fails

Problem scenario: The form is set to absolute positioning , there is a button in the form, the button is registered with the onclick event, and it is found that the button does not respond;

Problem solving: Open the webpage in chrome, move the mouse to the button and right-click to check, and find that the html element defined behind the form is on the upper layer of the button. It can be seen that when we click the button, we don't actually click the button.. ....

Just add a line of code to the absolute positioning style of the form to make the button float:

position: absolute;
z-index: 99;//添加该行代码即可

 Reprinted from: After the html element sets position:absolute absolute positioning, the onclick click event fails icon-default.png?t=M276https://blog.csdn.net/chelongfei/article/details/101218543?ops_request_misc=&request_id=&biz_id=102&utm_term=%E5%AE%9A %E4%BD%8D%E5%88%B0%E8%A1%A8%E5%8D%95%E7%82%B9%E5%87%BB%E4%BA%8B%E4%BB%B6%E5 %A4%B1%E6%95%88&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-0-101218543.142^v5^control,157^v4^control&spm=1018.2226.3001.4187

Guess you like

Origin blog.csdn.net/weixin_57607714/article/details/123991059