javascript - How create dynamically selectmenu in jQuery Mobile? -


i trying dynamically create select element, isn't styled jquery mobile. correct way achieve this?

jsfiddle

here's working jsfiddle example: http://jsfiddle.net/gajotres/dexac/

$(document).on('pagebeforeshow', '#index', function(){         // add new select element         $('<select>').attr({'name':'select-choice-1','id':'select-choice-1'}).appendto('[data-role="content"]');     $('<option>').attr({'value':'1'}).html('value 1').appendto('#select-choice-1');     $('<option>').attr({'value':'2'}).html('value 2').appendto('#select-choice-1');         // enhance new select element     $('select').selectmenu(); }); 

also take @ article, there find different method of enhancing jquery elements markup, or can found here.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -