Change button text jquery mobile

后端 未结 10 933
傲寒
傲寒 2020-11-29 04:32

I\'m using the new jquery mobile 1.0 alpha 1 release to build a mobile app and I need to be able to toggle the text of a button. Toggling the text works fine, but as soon a

10条回答
  •  不知归路
    2020-11-29 04:54

    For some reason I am not having an 'ui-btn-text' classed span the first time I want to change the button text. So I workaround it like this:

    var button = $("#consumed");
    var innerTextSpan = button.find(".ui-btn-text");
    
    // not initialized - just change label
    if (innerTextSpan.size() == 0) {
        button.text(label);
    
    // already initialized - find innerTextSpan and change its label    
    } else {
        innerTextSpan.text(label);
    }
    

提交回复
热议问题