user968477
user968477

Reputation: 41

Jquery Mobile checkbox click?

i have used code below on check box click. It works on local host but it not worked in mobile when i unchecked check box any one have solution for this?

$("#checkbox-1a").change (function(){
    var chkstatus = $(this).attr('checked'); 
    alert(chkstatus);
    if (chkstatus != 'checked') {
        $('#locationdiv').slideUp();
        $('#address').val('');
        $('#zip').val('');
    } else {
        $('#locationdiv').slideDown();
    }
});

Thanks in advance

Upvotes: 4

Views: 2781

Answers (2)

CoatedMoose
CoatedMoose

Reputation: 4258

Because jQuery mobile uses all that fancy markup, you need to call a special jQuery mobile function to update the check box.

$("#id").prop("checked", true/false).checkboxradio('refresh');

Works just fine. I think there are other ways to set the property, but make sure to include the refresh, otherwise jQm doesn't update the markup.

Upvotes: 5

williamcarswell
williamcarswell

Reputation: 673

have you tried the :checked selector?

Upvotes: 0

Related Questions