bantikyan / icheck-bootstrap

Pure css checkboxes and radio buttons for Twitter Bootstrap.
https://bantikyan.github.io/icheck-bootstrap/
MIT License
141 stars 35 forks source link

how to change the checked state with javaScript #7

Closed bosslichuan closed 5 years ago

bosslichuan commented 5 years ago

Sometimes, checkbox needs to change the state with js, so how can it do that. thanks!

bantikyan commented 5 years ago

Hello @bosslichuan , you have to change state similar as with regular input with type="checkbox". icheck-bootstrap is just css styling to change checkbox look.

With js you can look at: https://www.w3schools.com/jsref/prop_checkbox_checked.asp With jQuery: https://learn.jquery.com/using-jquery-core/faq/how-do-i-check-uncheck-a-checkbox-input-or-radio-button/

bosslichuan commented 5 years ago

Thanks for your solution. yeah, I had try to do like that with JQuery, but it didn't work. It still displayed as the initionalized style whether it had been checked or not.

I guess you will add the JS events to it. 😄😄

bantikyan commented 5 years ago

Hi @bosslichuan I think you are doing something wrong. Can you try with regular checkbox, on same place and see if it works?

About JS event, No. The idea of this project is to have all in pure css ;)

bosslichuan commented 5 years ago

Thanks, @bantikyan