Skip to content

Create from document.createElement #152

Closed Answered by palcarazm
cwolcott asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

You should add the input to DOM and then transform it to a toggle.

The plugin do not replace the reference of the input, the input is preserved wrapped into the toggle.

Here a live demo https://codepen.io/palcarazm/pen/ExGKqaB

// Create input
const toggle = document.createElement("input");
toggle.type = "checkbox";

// Add input to DOMM
const parentNode = document.querySelector("section");
parentNode.appendChild(toggle);

// Transform to toogle
toggle.bootstrapToggle();

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by palcarazm
Comment options

You must be logged in to vote
1 reply
@palcarazm
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants