は、だから、中に - 私のクリックのみ背景色を変更することが可能であるだけ - 私がテキストフィールドに
$('.parent > *')
.focus(function() {
$('.parent').addClass('focused');
})
.blur(function() {
$('.parent').removeClass('focused');
});
.parent {background: green}
.focused {background: red;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="parent">
<input class="childInput" type="text" />
<div class="sibling"></div>
</div>
<br><br>
<div class="parent">
<input class="childInput" type="text" />
<div class="sibling"></div>
</div>
をクリックすると、その要素で、この機能を入れて、それは可能ですか? parent
クラスと
$('.parent').addClass('focused');
だから、基本的にすべての要素: