Изменение текста в label в зависимости от checkbox при клике на div
Javascript
HTML
And don't forget to include jquery library. I'm working with jquery_1.7.1.min.js
See the example.
Javascript
$(document).ready(function () {
$(".markerDiv").click(function () {
var checkBox = $('input[name=markerType]', this);
$(checkBox).prop('checked', !checkBox.is(':checked'));
if ($(checkBox).is(':checked')) {
$("#markerLabel").text("en");
} else {
$("#markerLabel").text("ge");
}
});
});
$(".markerDiv").click(function () {
var checkBox = $('input[name=markerType]', this);
$(checkBox).prop('checked', !checkBox.is(':checked'));
if ($(checkBox).is(':checked')) {
$("#markerLabel").text("en");
} else {
$("#markerLabel").text("ge");
}
});
});
HTML
<div class="markerDiv" id="maker_school">
<div >
<label class="marker_label" for="kbd-switcher" id="markerLabel">Click here</label>
</div>
<input id="kbd-switcher" type="checkbox" class="marker_ckeckbox" name="markerType" style="display: none;" />
</div>
<div >
<label class="marker_label" for="kbd-switcher" id="markerLabel">Click here</label>
</div>
<input id="kbd-switcher" type="checkbox" class="marker_ckeckbox" name="markerType" style="display: none;" />
</div>
And don't forget to include jquery library. I'm working with jquery_1.7.1.min.js
See the example.
Комментариев нет:
Отправить комментарий