well-balanced

[TIL] 기록 29일차 본문

TIL : study log

[TIL] 기록 29일차

Cosmian 2019. 11. 29. 04:40

Today I Learned

DOM에서 제공하는 메소드 setAttribute, getAttribute에 대응되는 jQuery의 메소드는 attr, RemoveAttribute에 대응되는 메소드는 removeAttr이다.

object.setAttribute('class','important') // Attribute 방식
object.className('important') // property 방식
object.attr('class') // jQuery Attribute 방식
object.prop('class') // jQuery property 방식
<input id="checkBox"type="checkbox" checked="checked"/>
var checkBox = $('#checkBox')
console.log(checkBox.attr('checked');) // checked  
console.log(checkBox.prop('checked')); // true  
object.getBoundingClientRect() // object와 바디 사이의 거리 관계
// delay만큼의 간격을 두고 지속 실행하는 함수
setInterval(function,delay)
// 이벤트 전파 취소
function handler(event){
	console.log(this.nodeName)
}
function stopHandler(event){
	console.log(this.nodeName)
   	event.stopPropagation()
}
document.getElementById('target').addEventListener('click', handler, false)
document.querySelector('fieldset').addEventListener('click',stopHandler,false) // 이벤트전파 스탑
document.querySelector('body').addEventListener('click',handler, false)

target event -> fieldset event (stop) -> body event

 

 

 

'TIL : study log' 카테고리의 다른 글

[TIL] 기록 31일차  (0) 2019.12.01
[TIL] 기록 30일차  (0) 2019.11.30
[TIL] 기록 28일차  (0) 2019.11.28
[TIL] 기록 27일차  (0) 2019.11.27
[TIL] 기록 26일차  (0) 2019.11.26
Comments