У меня есть этот код, но он работает только с <img>
. Он изменяет изображение и добавляет значение к флажку. Я хотел бы, чтобы он работал с <i class='fa'></i>
. Что мне нужно изменить?Изменить <i> при нажатии на
$(".img-checkbox").click(function() {
var img = $(this);
alert(img.prev().prop('checked'));
if (img.prev().prop("checked")) {
img.css({
'opacity': '0.3'
});
} else {
img.css({
'opacity': '1.0'
});
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="checkbox-inline">
<input type="checkbox" name="qRequirements" hidden>
<i class="fa fa-phone fa-4x" class="img-responsive img-checkbox"></i>
</label>
<label class="checkbox-inline">
<input type="checkbox" name="qRequirements" hidden>
<i class="fa fa-user fa-4x" class="img-responsive img-checkbox"></i>
</label>
<label class="checkbox-inline">
<input type="checkbox" name="qRequirements" hidden>
<i class="fa fa-mail fa-4x" class="img-responsive img-checkbox"></i>
</label>
Не могли бы вы сделать описание вашего вопроса лучше? Я не могу понять предложения. –
Также обратите внимание, что атрибут ['hidden'] (https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden) не поддерживается в