user3692451
user3692451

Reputation: 569

var checkedValue - Jquery - how to change language?

I am using this to extract a checkbox value:

var checkedValue = $('.messageCheckbox:checked').val();

However, when the checkbox is on, it displays "On", when is off, it displays nothing.

Like this:

Is checked (Yes): On
Is checked (No):

What should I change to make it appear on/off, and how can I change the language or at least edit the result's text?

Upvotes: 0

Views: 46

Answers (2)

rxjmx
rxjmx

Reputation: 2181

Try this.

 var text = checkedValue ? 'Yes' : 'No';
 console.log(text);

https://jsfiddle.net/twugud15/

Upvotes: 1

mgamon
mgamon

Reputation: 308

Change to:

var checkedValue = $('.messageCheckbox').val();

Upvotes: 0

Related Questions