<button id = 'btn'>按钮</button>
1.原生写法
document.getElementById('btn').addEventListener('click',function(){
alert('芝士雪豹')
});
2.jQuery写法
$('#btn').click(function(){
alert('芝士雪豹')
})
3.onclick绑定
<button id = 'btn' onclick='btn()'>按钮</button>
function btn() {
alert('芝士雪豹')
}