开发者

Changing the label of a JQuery Mobile checkbox

开发者 https://www.devze.com 2023-04-01 18:37 出处:网络
I have the following checkbox: <input type=\"checkbox\" id=\"ui-5\"/><label for=\"ui-5\">checked</label>

I have the following checkbox:

<input type="checkbox" id="ui-5"/><label for="ui-5">checked</label>

I'd like to change its value to unchecked if its not checked and checked if it is checked. I've tried this code:

$("#ui-5").click(functio开发者_高级运维n(){
   $("label[for='ui-5']").text("unchecked");
});

It changes the label but the design of my checkbox becomes weird. How can I fix this?


JQuery mobile changes the original html of the page, this seems to work:

 $("#ui-5").change(function () {
    $("label[for='ui-5'] span.ui-btn-text").text("unchecked");
 });
0

精彩评论

暂无评论...
验证码 换一张
取 消