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://cdiso.cn/article/jdhspp.html