small steps/1일 1코딩 - 코딩을 내 몸처럼
[1일1코딩][jQuery] mouseenter & mouserout + attr
꿈꾸는개발자maker
2022. 4. 19. 21:22
728x90
attr() : 문서 객체의 특정 속성값을 알아내거나 추가할 때 사용
attribute 속성
// 메소드 체이닝 , 여러개의 속성
$('input[password]').css('background','blue').css('color','blue');
//객체로 넣어주는 방법, 여러개의 속성
$('input[class~=text]').css({'background':'green','color':'red'});
// Uncaught SyntaxError: Unexpected string 오류 - 키값잘못연결해서났음
// $('input[size]').css('backgroundColor','green');
$('input[class$=order]').css('backgroundColor','red');
$('input[type=number]').attr('placeholder','폰번호');
// 마우스 호버시 // 마우스 아웃시 -> 메소드 체이닝 가능
$('input:image').mouseenter(function(){
$(this).attr('src','../images/city1.png');
}).mouseout(function(){
$(this).attr('src','../images/river2.png')
})
728x90
반응형