Search code examples
jquerycssjquery-mobilejquery-mobile-button

Style JQuery created button with JQuery Mobile CSS?


In my JQ Mobile project I am using JQuery to create a button and append it to a div:

      var input = '<input type="button" class="save_event" value="Save"/>';
      $('.event').append(input);

However, this button seems exempt from Jquery Mobiles styling - it just appears as a normal webkit button. Would anyone know of a way to allow JQM's CSS to style this element?


Solution

  • You also need to do:

    $('[type="button"]').button();
    

    Working example: http://jsfiddle.net/Gajotres/m4rjZ/

    If you want to find out more about styling of dynamically created jQM elements take a look at my other answer: jQuery Mobile: Markup Enhancement of dynamically added content