특정 속성을 제거하는 방법 - .removeAttr()

removeAttr은 선택한 요소의 특정 속성을 제거합니다.
1 min read

.removeAttr()

.removeAttr()은 선택한 요소의 특정 속성을 제거합니다.

 

기본형

.removeAttr( attributeName )

예를 들어

$( 'h1' ).removeAttr( 'title' );

은 h1 요소에서 title 속성을 제거합니다.

 

예제

input 요소의 placeholder 속성을 제거합니다.

<input type="text" name="address" placeholder="Input Address">
<button class="a">Click to removeAttr</button>
input {
  display: block;
  font-size: 30px;
}
$( document ).ready( function() {
  $( 'button.a' ).click( function() {
    $( 'input' ).removeAttr( 'placeholder' );
  });
});

You may like these posts

  • .append() .append()는 선택한 요소의 내용의 끝에 콘텐트를 추가합니다.   기본형 .append( content [, content ] )   예를 들어 <p>Lorem Ipsum Dolor</p> 가 있을 때 $( 'p' ).appen…
  • .attr() .attr()은 요소(element)의 속성(attribute)의 값을 가져오거나 속성을 추가합니다.   기본형 1 .attr( attributeName ) 선택한 요소의 속성의 값을 가져옵니다. 예를 들어 $( 'div' ).attr( 'class' ); 는…
  • .before() .before()는 선택한 요소 앞에 새 요소를 추가하거나, 다른 곳에 있는 요소를 이동시킬 수 있습니다.   기본형 .before( content [, content ] ) 예를 들어 $( 'h1' ).before( '<p>Hello</p>'…
  • .click() .click()은 선택한 요소를 클릭했을 때 특정 작업을 수행할 수 있게 하는 속성입니다.   기본형 .click( handler ) 예를 들어 button 요소를 클릭했을 때 함수를 실행시키고 싶으면 다음과 같이 합니다. $( 'button' ).clic…
  • .children() .children()은 어떤 요소의 자식 요소를 선택합니다.   기본형 .children( [ selector ] ) 예를 들어 $( 'div' ).children().css( 'color', 'blue' ); 는 <div> 요소의 자식 요소의 색을 파란색으…
  • .appendTo() .appendTo()는 선택한 요소를 다른 요소 안에 넣습니다.   기본형 .appendTo( target ) 예를 들어 $( 'p' ).appendTo( 'blockquote' ); 는 <p> 요소를 <blockquote> 요소 안으로 …

Post a Comment