728x90

 

stackoverflow.com/questions/15266533/jquery-attrchecked-checked-works-only-once

 

jquery attr('checked','checked') works only once

I have a problem finding reason for the following jquery/checkbox behaviour. $( this.obj + ' table.sgrid-content > thead > tr > th > input.select_all' ).on( 'click' , {grid:this} , fun...

stackoverflow.com

답은 간단하게 .attr 대신  .prop 를 사용하는 것이다.

 

//$('input:checkbox[id="is_include_fees"]').attr("checked", false);
$('input:checkbox[id="is_include_fees"]').prop('checked', false);

 

 

You can change the attribute, and that will also change the property, if the element is untouched. Once the element leaves this initial state, changing the attribute no longer affects the property. The exact behavior probably varies between browsers.

 

 

Instead of .attr('checked', 'cheked') use .prop('checked', true)

+ Recent posts