Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding jquery ui icon to a submit button

I have the following code for a submit button my page: The html markup is:

<td align="Right"><input type="submit" value="Add Driver" ></td>

and the jquery is:

$( "input[type=submit]" ).button().click(function( event ) {
event.preventDefault();
});

How would I add a ui icon to the above, specifically the ui-icon-circle-plus

like image 685
Robert Martens Avatar asked Feb 06 '13 16:02

Robert Martens


2 Answers

You can change your HTML like this:

<button type="submit">
    Add Driver
</button>

And then update your script like this:

$('button[type=submit]').button({icons: {primary: 'ui-icon-circle-plus'}}).click(function (event) {
    event.preventDefault();
});

Demo: http://jsfiddle.net/mh5Pu/

like image 118
Viktor S. Avatar answered Oct 11 '22 12:10

Viktor S.


Look at the examples on http://jqueryui.com/button/#icons (specifically the icons).

Instead of using a submit input, try using a button.

Here's a modified version of the icon only button with ui-icon-circle-plus:

<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only"     role="button" aria-disabled="false" title="Button with icon only">
<span class="ui-button-icon-primary ui-icon ui-icon-circle-plus"></span>
<span class="ui-button-text">Button with icon only</span>
</button>
like image 29
Ben Inkster Avatar answered Oct 11 '22 11:10

Ben Inkster