[JavaScript] jquery 操作css样式 →→→→→进入此内容的聊天室

来自 , 2019-03-27, 写在 JavaScript, 查看 112 次.
URL http://www.code666.cn/view/e52ad5c9
  1. //获取样式
  2. $("input:eq(0)").click(function () {
  3.     alert($("p").attr("class"));
  4. });
  5. //设置样式
  6. $("input:eq(1)").click(function () {
  7.     $("p").attr("class", "high");
  8. });
  9. //追加样式
  10. $("input:eq(2)").click(function () {
  11.     $("p").addClass("another");
  12. });
  13. //删除全部样式
  14. $("input:eq(3)").click(function () {
  15.     $("p").removeClass();
  16. });
  17. //删除指定样式
  18. $("input:eq(4)").click(function () {
  19.     $("p").removeClass("high");
  20. });
  21. //重复切换样式
  22. $("input:eq(5)").click(function () {
  23.     $("p").toggleClass("another");
  24. });
  25. //判断元素是否含有某样式
  26. $("input:eq(6)").click(function () {
  27.     alert($("p").hasClass("another"))
  28.     alert($("p").is(".another"))
  29. });
  30.  

回复 "jquery 操作css样式"

这儿你可以回复上面这条便签

captcha