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.
The
click
of the
element should have the same effect as the manual click.First of all
b.className
is notb.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 addingdocument.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 calldispatchEvent()
…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