jQuery边框不会改变颜色

时间:2018-10-25 20:00:12

标签: jquery css3

.modal-register-form {
	width: 400px;
	height: auto;
	position: absolute;
	top: 50%;
	left: 0;
	transform: translateY(-50%);
}

.modal-register-form .user-input {
	width: 70%;
	margin: 25px auto 0;
}

.user-input input {
	font-family: 'Karla', sans-serif;
	font-size: 14px;
	color: #8d8d8d;
	padding: 0 16px;
	border: none;
	border: 1px solid #e5e5e5;
	border-radius: 3px;
	height: 32px;
}

setTimeout(function()
{
    $('.modal-register-form :input[type=text], .modal-register-form :input[type=email], .modal-register-form :input[type=password]').each(function()
    {
        if ($(this).css('border-color') == 'rgb(254, 0, 0)')
        {
            alert('working');
            $(this).css({
                border: '1px solid #e5e5e5'
            });
        }
    });
}, 3250);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>

有人知道为什么我的代码不起作用吗?如果单击该按钮,则会收到“正在工作”的警报,但边框不会更改其颜色。

感谢您的支持。

关于, 桑德罗

2 个答案:

答案 0 :(得分:0)

代替:

border: '1px solid #e5e5e5'

使用此:

"border": "1px solid #e5e5e5"

答案 1 :(得分:0)

尝试使用 not 组合符号,但仅使用border-color的特定单个属性,并采用以下方式(在属性和值两边都用引号引起来,用逗号隔开):

$(this).css({
  "border-color", "#e5e5e5"
});
相关问题