I have an input form e.g.
<input type="checkbox" id="a.b">
I want to print its value whenever I click on it using the console.log()
javascript function.
<input type="checkbox" id="a.b" onclick="console.log(a.b.value)">
Obviously, Javascript complains that a is undefined and that the property b of value does not exist. The only way I found of doing this was to rename my field using _ instead of a . (period). I end up with
<input type="checkbox" id="a_b" onclick="console.log(a_b.value)">
Is there a better way? Can I escape dots in identifiers? I am aware that . is an invalid character in Javascript identifiers but it is not in HTML. Can I get around this issue using jquery?