본문 바로가기
반응형

Web Programing!/JQuery39

[JQUERY] checkbox, radio 체크가 되지 않을때 (.attr과 .prop의 차이) jQuery에서 엘리먼트의 속성을 동적으로 변경시키기 위해 .attr 메서드를 흔히 사용합니다. 폼 요소에서도 checkbox나 radio에 체크값에 변경을 주기 위해 .attr 메서드에 checked 값을 넣었지만 동작하지 않았습니다. jQuery 1.6 버전부터 .attr 메서드의 기존 역할은 .attr과 .prop로 나뉘어지게 되었다는걸 알았습니다. .attr과 .prop 메서드의 차이는 간단합니다. html 어트리뷰트와 javascript의 속성을 컨트롤하는 차이입니다. 체크박스나 라디오버튼은 html 어트리뷰트를 변경해도 변화가 없음을 확인 할 수 있습니다. .attr로 체크값을 변경해도 화면에서는 변동이 없고 코드상에서만 변동이 있었습니다. 이런 증상이 있다면 .attr 메소드를 .prop 메.. 2014. 8. 8.
[JQUERY] input readonly 백스페이스(backspace) event.keyCode 처리 [JQUERY] input readonly 백스페이스(backspace) event.keyCode 처리 input type text에 readonly가 쓰일때가 있다. 그때 커서를 선택하고 Backspace Key를 누르게되면 뒤로가게된다. 그것을 막아주는 이벤트 스크립트. $( '#selector' ).keydown(function(event) { if ( event.keyCode === 8 ) { return false; } }); 2014. 6. 15.
JQuery API 따라잡기 : 해당 객체의 아이디 가져오기 JQuery API 따라잡기 : 해당 객체의 아이디 가져오기 $('selector').attr("id"); 해당 'selector' 위치의 아이디 가져온다. 2014. 2. 26.
JQuery API 따라잡기 : Class 객체 찾기 - .hasClass () jQuery에서 Class 객체 찾기 - .hasClass () 원문 : http://api.jquery.com/hasClass/ 설명 : 일치하는 요소 중 하나가 주어진 클래스를 할당 여부를 결정합니다. .hasClass() 함수는 클래스명이 일치하는 것이 있을 경우 리턴값으로 true, false 를 반환합니다. 소스보기 This paragraph is black and is the first paragraph. This paragraph is red and is the second paragraph. First paragraph has selected class: Second paragraph has selected class: At least one paragraph has selected cla.. 2014. 2. 25.
반응형