html input addclass,html - jquery add class to parent on input focus - Stack Overflow

I have a contact form. I want to add class to parent div of the input box on the input:focus.

Here is the fiddle . I want that not just the input box but the div background color should change to purple on the input focus.

Markup:

name

Javascript:

jQuery(document).ready(function($) {

$(".round_text:focus").parent().css('background', '#8b66ac');

$('.round_text:focus').parent().css('background-color', 'red');

});

CSS:

.round {

background: none repeat scroll 0 0 #F3F3F3;

border-radius: 30px 30px 30px 30px;

border-top: 1px solid #B2B2B2;

height: 50px;

padding-left: 20px;

width: 440px;

}

.round_text:focus {

background: none repeat scroll 0 0 #8b66ac;

}

.round_label {

border-right: 1px solid #D1D1D1;

color: #B6B6B6;

float: left;

font-size: 16px;

height: 40px;

padding-top: 10px;

width: 156px;

}

.round_text {

background: none repeat scroll 0 0 #F3F3F3;

border: medium none;

color: #424242;

float: left;

height: 50px;

width: 240px;

}

Also, Can you help me as if i need to add two properties eg:

$(".round_text").focus(function(){

$(this).parent().css('background', '#8b66ac','color','#fff');

}).blur(function(){

$(this).parent().css('background', /*color*/);

})

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值