selector
html原生选择器###
有3种
- id
- class
- tagName
//id
document.getElementById('id')
//class
document.getElemntByClass('class')
//tagName
document.getElementByTagName('tagName')
其实也不用这么麻烦,在没有jquery的情况下,依然可以搞定;它就像jquery一样,用起来很方便~!
querySelector('#id')
querySelector('.class')
事件驱动
addEventListener('事件名',cb)
document.querySelector('p').addEventListener('click',function(){
querySelector('.class').innerHTML="I love you"
})
You can change the world with your heart,even a lot of changes sometimes unless you won't geiv up....