jeudi 28 janvier 2016

Error with html checkbox value retrieval

In my html I have:

<div id="case_filter" style="float: bottom">
   <input type="checkbox" name="bC" value="B C" checked> No B C<br>
   <input type="checkbox" name="fN" value="f NC" > No F NC<br>
   <input type="checkbox" name="rR" value="RR" > No RR<br>
</div>

I kept the first checkbox checked by default. I want to access the value of the checkbox in my JS. I am doing this below, but it returns null (when I console.log it).

 var checkedValue = document.querySelector('.bC:checked').value;




Aucun commentaire:

Enregistrer un commentaire