removeAttr 메서드

removeAttr 메서드는 요소의 속성을 제거합니다.

문법

javascript$(selector).removeAttr(attributeName);

예제

인풋 요소의 value 속성을 제거해 봅시다:

html<input type="text" value="!!!" id="test">
javascript$('#test').removeAttr('value');

HTML 코드는 다음과 같이 변경됩니다:

html<input type="text" id="test">

같이 보기

  • 요소의 속성을 가져오고 변경할 수 있는 메서드 attr
  • 요소의 프로퍼티를 다룰 수 있는 메서드 prop
  • 요소의 프로퍼티를 제거할 수 있는 메서드 removeProp