jQuery与原生js的函数对比
原生js | jQuery |
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的函数对比
浏览路径:http://scyanting.com/article/jdhspp.html