How to create the button dynamically using jQuertMobile.
This example demonstrates how do I add a button dynamically in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
In vanilla JavaScript, you can use the document. createElement() method to programmatically create an HTML button element and set its required attributes. Then to append the button to a container, you can use the Node. appendChild() method.
Very simple:
First create a button HTML JQuery element by:
var button = $("<button>My Button</button>");
Next, inject the button wherever you want it to be in the page:
$("#my_button_div").append(button);
And finally run the button() JQuery Mobile command on the button:
button.button();
You should have a functional and JQM styled button in your page by now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With