一.設定屬性:
方式一 jQuery 代碼:
$("img").attr({ src: "test.jpg", alt: "Test Image" }
方式二:jQuery代碼--鍵值對
$("img").attr("src","test.jpg");
方式三: jQuery 代碼--函數式:
$("img").attr("title", function() { return this.src });
二、添加Class
方式一:
三、删除class
方式一:
四、切換Class
方式一:
五、添加Css格式
方式一:
$("p").css({ color: "#ff0011", background: "blue" });
方式二:鍵值對
六、移除Css樣式
方式一、移除全部使用removeattr("style"); 方式二、移除單個使用css("屬性","");