Like
var text = $('#thetext').val();
status.text('On input writed text is'+ text +'');
This get the value writed there but from a .prop
how get value? Is checked or not? Like checkbox is checked
Like
var text = $('#thetext').val();
status.text('On input writed text is'+ text +'');
This get the value writed there but from a .prop
how get value? Is checked or not? Like checkbox is checked
I have an
<input id="checkboxid" type="checkbox">
and I want to write a text for it if is checked write blablabla but if is not checked then write nothing with at message id
var checkbox = $(‘#checkboxid’).prop();
$(‘#message’).text(‘+ checkbox +’)
Here is an example:
<input id="checkbox-id" type="checkbox"> My Checkbox
<div>
<button id="btn">Check Status</button>
</div>
<div id="status"></div>
$("#btn").on('click', function() {
const checked = $("#checkbox-id").prop('checked');
$("#status").text('My checkox is ' + (checked ? '' : 'not') + ' checked.');
});
Here is another version with the event handler on the change event
<input type="checkbox" name="" id="checkbox">
<div id="output"></div>
$('#checkbox').on('change', function() {
$('#output').text($(this).prop('checked') ? 'checked' : '')
})