selecting checked radio inputs and filtering by html data attributes
Hello. I know some vanilla javascript but am new to jQuery.
I am trying to select checked radio inputs and then select only the ones whose html I have given a data-attribute of correct answer like so:
- data-answer="correctanswer"
My jQuery currently looks like this.
- var checkedbox = $("[type='radio']").attr(":checked") === true;
- checkedbox.data( "answer" ) === correct answer;
I then want to do .length of the variable so I can see how many correct answers people have given in a quiz.