문제

How to get the check box state when it is changed. I am using zurb foundation

<label for="checkbox3"><input id="checkbox2" type="checkbox" name="chk[2]"></input>
   <span class="custom checkbox" onclick="toggleState(2)"></span>
   Check Box 1
</label>

But in function state prior to clicked is shown. How should i get the latest value Please Help

도움이 되었습니까?

해결책

I would remove the onclick="toggleState(2)" and try some jquery code similar to:

$('#checkbox2').on('change', function() {
  console.log($(this).is(':checked'));
});

Also, you should change your label to <label for="checkbox2"> rather than <label for="checkbox3"> as an element with the id checkbox3 doesn't exist.

It would also help if you could mention what version of Foundation you are using.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top