1

I have a mobile client and have a simple problem.

Here is my html part:

<label id="112233" for="checkbox-detailed_limit">Take Profit</label>
<input type="checkbox" name="checkbox-detailed_limit"
id="checkbox-detailed_limit" data-mini="true"/>

I want to change checkbox's checked status, when the container page is displayed.

I have used javascript and jquery for this action but all failed.

Here are some examples:

$("#checkbox-detailed_limit").attr("checked", false).change();
$("#checkbox-detailed_limit").attr("checked", false).trigger("change");
$("#checkbox-detailed_limit").prop("checked", false);
$("#checkbox-detailed_limit").removeAttr("checked");
$('input:checkbox', $("#112233")).prop("checked", false);
$("#112233").filter(':checkbox').prop("checked", false);
$('input').filter(':checkbox').prop('checked',false);
$("#112233").children('input[type="checkbox"]').prop('checked', false);
$("#112233").find("checkbox").attr("checked", false);
document.getElementById("checkbox-detailed_limit").checked = false;

Is there any way to help me?

Zim84
  • 3,404
  • 2
  • 35
  • 40
Ceyhun Erdil
  • 13
  • 1
  • 4

5 Answers5

2

This is actually a jquery-mobile problem, since these checkboxes will get enhanced.

$("#checkbox-detailed_limit").attr("checked",true).checkboxradio("refresh");

Source: http://jquerymobile.com/demos/1.2.0/docs/forms/checkboxes/methods.html

Zim84
  • 3,404
  • 2
  • 35
  • 40
0

I am not sure what you really want, but you want to set checked status to checkbox ? then this can be done like this.

$("#checkbox-detailed_limit").prop("checked", true); //for jquery 1.7+ 

$("#checkbox-detailed_limit").attr("checked", true); //for jquery < 1.7  
Ravi Gadag
  • 15,735
  • 5
  • 57
  • 83
0

To Check the Check box:

$("#"+id).attr("checked", "checked");

To Uncheck the checkbox:

$("#"+id).removeAttr("checked");
Mallikarjuna Reddy
  • 1,212
  • 2
  • 20
  • 33
0

Try this,

   $("#checkbox-detailed_limit").prop("checked", true);
   $("#checkbox-detailed_limit").prop("checked", false);
DrColossos
  • 12,656
  • 3
  • 46
  • 67
EnterJQ
  • 1,014
  • 8
  • 18
0
$('input[name=foo]').attr('checked', !$('input[name=foo]').is(':checked')); 

This script will toggle the checkbox and should work absolutely fine. If this is not working you have an error in your javascript code somewhere else. Using a console will help you finding your problem.

yan.kun
  • 6,820
  • 2
  • 29
  • 38