1烟勋、html() 取出或設(shè)置html內(nèi)容?
取出html內(nèi)容
var $htm = $('#div1').html();
設(shè)置html內(nèi)容
$('#div1').html('<span>添加文字</span>');
2桶良、text() 取出或設(shè)置text內(nèi)容
取出文本內(nèi)容
var $htm = $('#div1').text();
設(shè)置文本內(nèi)容
$('#div1').text('<span>添加文字</span>');
3传货、attr() 取出或設(shè)置某個(gè)屬性的值
取出圖片的地址
var $src = $('#img1').attr('src');
設(shè)置圖片的地址和alt屬性
$('#img1').attr({ src: "test.jpg", alt: "Test Image" });
jquery特殊效果:
fadeIn() 淡入
? ? $btn.click(function(){
? ? ? ? $('#div1').fadeIn(1000,'swing',function(){
? ? ? ? ? ? alert('done!');
? ? ? ? });
? ? });
fadeOut() 淡出
fadeToggle() 切換淡入淡出
hide() 隱藏元素
show() 顯示元素
toggle() 依次展示或隱藏某個(gè)元素
slideDown() 向下展開
slideUp() 向上卷起
slideToggle() 依次展開或卷起某個(gè)元素