javascript - What is the difference between directly clicking a button to trigger an event and calling click to trigger an event through JS?
巴扎黑
巴扎黑 2017-06-28 09:27:32
0
4
846

巴扎黑
巴扎黑

reply all(4)
学霸

The

click of the element should have the same effect as the manual click.

First of all b.className is not b.class

Although I have never used this Clipboard library, literally it is to obtain the .copybutton class through the selector, so you should not be able to obtain it without mounting b on the dom tree. You can try adding document.body.appendChild(b) in front.

Finally, I suggest you ask questions in the same way as the comments above. Post more code and less pictures, which is inconvenient to read.

某草草

Um, .click()That’s the abbreviation of jQ, natively you have to call dispatchEvent()


Reference

三叔

Problem: Native objects and jq objects are mixed up
Change the first line to:
var $b = $('<input type="button" />') Try it

给我你的怀抱

You can bind its click event through the body

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!