Change data-icon on click with jquery mobile

前端 未结 4 1148
独厮守ぢ
独厮守ぢ 2021-01-18 12:58

This is my code:

function togglePOIAndDisplay(toggle){
    var display = $(toggle).attr(\'data-icon\');
    console.log(display);
    if(display == \'minus\'         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-18 13:48

    If the icon is inside a button like this:

    Button
    

    You can change the icon with the buttonMarkup function:

    $('#buttonID').buttonMarkup({ icon: "check" });
    

    Or to your custom icon:

    $('#buttonID').buttonMarkup({ icon: "my-icon" });
    

    Example: http://jsfiddle.net/u8fnJ/1/

    As shown in this post How to refresh a button in a header with jQueryMobile?

提交回复
热议问题