자바스크립트/jQuery
jQuery 메소드
Socratone
2020. 2. 25. 03:41
$( "#target" ).css( "background-color", "yellow" );
// target 엘리먼트에 background-color라는 CSS 속성을 추가하고 yellow 값을 넣는다.
$( "#target" ).attr( "title", "blog" );
// target 엘리먼트에 title이라는 속성을 추가하고 blog 값을 넣는다.
$( "#target" ).val();
// target 엘리먼트의 value 값을 반환한다. <input>, <select>, <textarea> 한정
$( "#target" ).text(); // target 엘리먼트의 텍스트 노드를 반환한다.
$( "#target" ).text( "<p>This is a test.</p>" ); // target 엘리먼트에 글자를 넣는다.
$( "#target" ).click(function() {
// target 엘리먼트를 클릭했을 때
});
$( "#target" ).keyup(function() {
// target 엘리먼트가 focus돼 있을 때 키를 누르면
});