Check if checkbox is checked

Hi, this is my function

$(".ck-button input, #toggleChecked, .mainDesign").each(function(){

What I want to do is if the checkbox or radio buttons are checked then put the value into the #totalVal tag. The above works if the form has an error, but when you first click the checkbox it doesn’t.

This works -

$(".ck-button input, #toggleChecked, .mainDesign").click(function(){

But if the form has an error then totalVal isn’t inputted into #totalVal?

I’d appreciate some help!

first works for one case and second for another
so… use both?

I did think about doing that, but thought it was messy. is there a way to achieve this with just one function?

Can you please provide us with more of the code, so that we can better simulate the radio and checkboxes and form errors that you’real wanting to deal with?

I think that using some variation of $(document).on(‘selectors’, ‘click’, function() {…}) may be useful. But unless we can test it with your actual code, it’s difficult to tell for sure.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.