网站建设资讯

NEWS

网站建设资讯

jQuery与原生js的函数对比

原生jsjQuery
document.title$('title')
docuemnt.getElementsByTagName('TagName')$('TagName')
document.getElementById('id')$('#id')
document.getElementsByClassName('ClassName')$('.ClassName')
document.querySelectorAll('.Class Tag')$('.Class Tag')
DOM.getAttribute('src')$(selector).attr('src')
DOM.setAttribute('src')$(selector).attr('src','value')
DOM.innerHTML$(selector).html()
DOM.style.color$(selector).css('color')


document.createElement('div')
document.createTextNode('text')
ourDiv.appendChild(newParagraph)
ourDiv.insertBefore(newHeading,para)
ourDiv.replaceChild(newImg, swapMe)
parentDiv.removeChild(removeMe)


document.onload = function(){...}$(document).ready(function(){...})













本文标题:jQuery与原生js的函数对比
URL标题:http://cdweb.net/article/jdhspp.html