본문 바로가기
Java Script/Jquery

jQuery] attributes 변경하기

by CodeMia 2021. 9. 3.

HTML가 이렇게 세팅되어있을 때

빨간 박스가 attributes이다. 

 

 

jQuery로 attribute 보는 법

 

이미지 태그 안 scr attribute보기

drum.png라고 나옴

 

 

a 태그 안에 있는 attribute보기 

 

 

클래스 보기

class도 attribute이다.

 

 

 

jQuery로 attribute 세팅 하는법

 

href를 구글에서 네이버로 변경해보기 

attr() 메소드의 첫 번째 인풋은 뭘 바꿀지 두 번째 인풋은 뭘로 바꿀지를 적으면 된다. 

 

 

클래스 추가/ 삭제는 

.addClass("")  .removeClass("")로 한다. 

 

 

 

댓글