Home > Web Front-end > JS Tutorial > body text

Solution to onclick failure problem after calling innerHTML_javascript skills

WBOY
Release: 2016-05-16 17:02:02
Original
1589 people have browsed it

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:














Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template