[0]很重要 = 。=
$('#name')[0].style.border="1px solid red";
$('#password')[0].style.border="1px solid red";
$('#btnLogin').on('click', function () {
$.ajax({
url: "/login",
type: "POST",
dataType: "json",
data: $('#myLogin').serialize(),
cache: false,
success: function (data) {
if (data.code == "1" && data.msg == 'success') {
setTimeout(function(){
location.replace('/index');
}, 1000);
}else if(data.code == -1){
$('#notice').html(data.msg);
$('#name')[0].style.border="1px solid red";
$('#password')[0].style.border="1px solid red";
}
},
error: function (data) {
window.alert('登陆失败');
window.location.href="/login";
}
});
});