我将如何定位单个input focus
.
$(".right input").focus(function(){
$(".left span").addClass('focus');
}).blur(function(){
$(".left span").removeClass('focus');
});
span
此代码在我关注时将类添加到所有元素我将input
如何设置它以便它只能将类添加到input
正在关注的元素?这是我的html
<div class="left">
<span class="name"></span>
<span class="email"></span>
<span class="phone"></span>
<span class="address"></span>
</div>
<div class="right">
<p>
<label for="name">Your Name:</label>
<input id="name" type="text" value="Name" autocomplete="off">
</p>
<p>
<label for="email">Email Address:</label>
<input id="email" type="text" value="Email" autocomplete="off">
</p>
<p>
<label for="phone">Phone Number:</label>
<input id="phone" type="text" value="Phone" autocomplete="off">
</p>
<p>
<label for="address">Your Address:</label>
<input id="address" type="text" value="Address Line 1" autocomplete="off">
</p>
<p>
<label for="address2">Line Address 2:(optional)</label>
<input id="address2" type="text" value="Address Line 2" autocomplete="off">
</p>
</div>
编辑 我可以实现在选择此代码的答案中给出的代码吗?
// Trying to target font customization on single input focus
// and not all together
$("#fs").change(function() { // change font family style.
$('.email').css("font-family", $(this).val());
});
$("#size").change(function() { // change font size.
$('.email').css("font-size", $(this).val() + "pt");
});
要编辑span
属于input
那个重点?