Converting jQuery to JavaScript
Last updated
Last updated
셀렉터
2. 입력값 셋팅
3. 이벤트 리스너
4. 조상 요소 핸들링 차이점
jQuery
JavaScript
5. 클래스 조작
6. CSS 스타일링
7. 스크롤 위치
8. 유틸
9. 원소 생성 및 추가
jQuery
JavaScript
10. 카피 추가
jQuery
JavaScript
11. HTML string 추가
jQuery
JavaScript
12. Attributes
13. Properties
jQuery
JavaScript
$("body")
document.body
$("html")
document.documentElement
$(selector)
document.querySelector(selector)
$elem.find(selector)
elem.querySelector(selector)
$elem.parent()
elem.parentNode
$elem.closest(.'country')
elem.closest('.country')
$input.closest('form')
input.form
siblings:$el.prev() and $el.next()
el.previousElementSibling and el.nextElementSibling
jQuery
JavaScript
$input.val()
input.value
$input.val("hello")
input.value
jQuery
JavaScript
$elem.on(eventName,handler)
elem.addEventListener(eventName, handler)
$elem.off(eventName)
elem.removeEventListener(eventName, handler)
jQuery
JavaScript
$elem.addClass(c)
elem.classList.add(c)
$elem.removeClass(c)
elem.classList.remove(C)
$elem.toggleClass(c)
elem.classList.toggle(c)
$elem.hasClass(c)
elem.classList.contains(c)
$elem.attr('clsss') = 'some classes'
elem.className = 'some classes'
jQuery
JavaScript
$el.css({top:"10px"})
el.style.top = "10px"
jQuery
JavaScript
$el.scrollTop()
el.scrollTop
$el.scrollTop(10)
el.scrollTop = . 0
jQuery
JavaScript
$.inArray(item,arr) > -1
arr.indexOf(item) > -1
$.extend({},defaults,options)
Object.assign(defaults, options)
$.trim(s)
s.trim()
$input.val()
input.value
jQuery
JavaScript
$elem.attr("placeholder")
elem.getAttribute("placeholder")
$elem.attr("placeholder",p)
elem.setAttribute("placeholder")
jQuery
JavaScript
$el.props("disabled")
el.disabled
$el.props("readonly")
el.readOnly