As you may have already noticed, most browsers do not support adding icons to <input type=”submit”> and <input type=”reset”> using jQuery UI. The code below will correct this issue by replacing matched <input> tags with appropriate <button> tags…
$(document).ready(function(){ $('input:submit, input:reset').each(function(){ $(this).replaceWith('<button type="' + $(this).attr('type') + '">' + $(this).val() + '</button>'); }); });
We loop through each submit and reset button and replace it with a button tag using the original input’s value as the new button’s text. Since we are using the original input’s value attribute, it should not be considered optional. Otherwise, you’ll end up with a button that has no text unless you set it explicitly with the .button({label: ‘my button label’}) option unless you intend to show only the icon by calling .button({text: false}) option.
Now we can assign icons to the buttons without updating the html using the following code… Continue reading