Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Button Dynamically - JQueryMobile

How to create the button dynamically using jQuertMobile.

like image 593
Finder Avatar asked Dec 28 '10 04:12

Finder


People also ask

How do you create a dynamic button?

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.

How do I create a dynamic button in HTML?

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.


1 Answers

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.

like image 141
Erez Rabih Avatar answered Oct 19 '22 17:10

Erez Rabih