选择器
css选择器:以字符串方式传入
$(document).ready(function() {
$('button').click(function() {
$('p').css('color','red').hide(3000);
});
});
对象
传递一个DOM对象,或者document对象,window对象给$()
$(document).ready(function() {
$('button').click(function() {
$('p').css('color','red').hide(3000);
});
});
HTML字符串
传递一个html文本给$(),这时$()自动创建这个元素
$(function() {
$("button").click(function() {
$('p').css('color'.'red');
$('<h1>html</h1>').appendTo(document.body);
})
})
回调函数
传递一个函数给$()
$(function() {
$("button").click(function() {
$('p').css('color'.'red');
})
})