Toggle the button icon in jQuery UI -


i using jquery ui button icon. want toggle icon of button onclick, working icons overriding :

/* initialize button @ document.ready event */ $("#buttonid"). button({ icons: { primary: 'ui-icon-play'} });  /* binding event */ $("#buttonid").toggle( function () {    /* code */    $(this).button({ icons: { primary: 'ui-icon-play'} }); },  function () {    /* code */    $(this).button({ icons: { primary: 'ui-icon-pause'} });  }); 

can point out problem?

you able change icon changing class associated it, no need additional interaction.

see working fiddle example!

jquery

$(function() {     $("#buttonid").button({         icons: {             primary: "ui-icon-play"         }     }).hover(function () {         // hover in         $(".ui-button-icon-primary", this)           .toggleclass("ui-icon-pause ui-icon-play");     }, function () {         // hover out         $(".ui-button-icon-primary", this)           .toggleclass("ui-icon-play ui-icon-pause");     }); }); 

since need change icon, , icon present @ style sheet specific class, need toggle class on over in/out, changing:

.ui-icon-play .ui-icon-pause , vice-versa.

see: jquery toggleclass

see: jquery ui icon classes (hover icon see class name)


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -