2012-07-12 44 views
0

目前我有一個JQueryMobile窗體,它有兩個文本框,但可能會出現這種情況,我必須添加幾個文本框。如何實現這一點?? ...在JQueryMobile UI中動態添加文本框。

例如,用戶將點擊屏幕上的添加按鈕,它會在屏幕上顯示一個新的文本框。我試圖追加,但沒有正常工作。

如何通過動態添加文本框到JQueryMobile表單實現此目的?

感謝您的時間提前。

+0

我還沒有嘗試過使用jquery mobile ui呢。代碼與你在jQuery中的做法不同嗎? – 2012-07-12 06:05:41

+0

邏輯應該與jquery相同。 – 2012-07-12 06:15:36

回答

1

你說你的評論,邏輯應該是與jQuery相同。在jQuery中我做這樣的事情來創建新的表單元素:

//element where you are going to append your dynamically created element 
var body = document.getElementsByTagName('body'); 

//create textbox and append it to the body of the document. 
$('<input>').attr({'type' : 'text', 'placeholder' : 'some text'}).appendTo(body);