My code runs unexpectedly, and I want to know why.
Basically, I press the button to change the value of the input text box. An entry has the identifier "here", but not a name or class. However, I can change its value using dot notationhere.value
Note that I use simple dot notation instead of the jQuery selector, parenthesis notation, or method getElementById(id). As far as I know, this should NOT work.
jsfiddle demo
<input id="here" readonly>
<input type="button" id="btn" value="Click">
<script>
$(document).ready(function() {
$('#btn').on('click', function() {
here.value = 'you clicked on the button';
});
});
</script>
source
share