2

Is it possible to remove the input type checkbox checked attribute on click of id="chk1" checkbox.

<div class="index1" id="test1">
    <h2>testing1</h2>
    <div class="str">
        <ul>
            <li class="nvc1">
                <input type="checkbox" value="in1" id="chk2" checked="checked" />
                <div class="checkbox-select">str1</div>
                <div class="checkbox-deselect">str2</div>
            </li>
        </ul>
    </div>
</div>
<div class="index2" id="test2">
    <h2>testing2</h2>
    <div class="string">
        <ul>
            <li class="nv1">
                <input type="checkbox" value="in1" id="chk1" />
                <div class="checkbox-select">lblstr1</div>
                <div class="checkbox-deselect">lblstr2</div>
            </li>
        </ul>
    </div>
</div>

Is there any reference for this/

Thanks, ShailShin

1
  • 1
    your JS snippet please Commented Jul 23, 2014 at 12:02

5 Answers 5

5

I suggest this:

$("#chk1").on("change", function(){
    $("#chk2").prop("checked", !$(this).prop("checked"));
});

Change #chk2 checked status depend on #chk1.

JSFiddle

Sign up to request clarification or add additional context in comments.

1 Comment

As per the question, this would be the answer. Voted.
2

In JQuery you can use:

jQuery('#chk1').click(function()
{
    jQuery('#chk1').removeAttr('checked');
});

But does it makes sense? :-)

Comments

2

In Jquery you can do this easily

http://jsfiddle.net/gcS4T/

$('#chk1').click(function () {
    $('#chk2').prop('checked', false);
});

Comments

0

id should be unique and to remove the 'checked' attribute you can use:

$(document).ready(function()({
   $('#chk1').click(function(){
      $('input:checkbox').prop('checked',false);

   //or 
  // $('input:checkbox').removeAttr('checked');
  });

});

Comments

0
$("#chk1").removeAttr('checked').checkboxradio('refresh');

Hope this helps....

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.