Home  >  Article  >  Web Front-end  >  Solution to onclick failure problem after calling innerHTML_javascript skills

Solution to onclick failure problem after calling innerHTML_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:02:021554browse

I recently wrote a project that used innerHTML. However, I found that after calling innerHTML, onclick failed. This is also expected, because innerHTML is a button inserted in the form of text, so the onclick event cannot be recognized. We have to find another way out. We cannot implement it directly, but we can achieve it indirectly. Here is an example:

Example 1: This example cannot be implemented onclick

Copy code The code is as follows:








< br />






The above example is to judge whether the button is online based on its name. Still offline~~~ We found that after the first click, the next click will be invalid~~~~~~

At this time we can implement it in disguise, as follows:
Copy code The code is as follows:














Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn