【问题标题】:Font-size and Font-family not changing through jquery字体大小和字体系列不通过 jquery 改变
【发布时间】:2020-11-26 11:14:36
【问题描述】:

你好,这是我的代码:- 代码 html-

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="icon" href="iconFavicon.png">
    <link rel="stylesheet" href="styles.css">
   
</head>
<body>
<p>My Text Has To Be Changed </>
<button>1</button>
<button>2</button>
<button>3</button>
<button>4</button>
<button>5</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="index.js"></script>
</body>
</html>

css-

.text-change{ 
    font-size:2rem;
    font-family:cursive;
    color:black;
}

javascript-

$("p").addClass(".text-change")

即使在 javascript 中编写此语句后,我也无法更改我的文本的字体大小或字体系列。任何形式的帮助将不胜感激。

【问题讨论】:

  • 删除 jQuery 代码中的点。类本身的名称中没有点。 $("p").addClass("text-change")
  • 谢谢@marks .. 它现在可以工作了

标签: javascript html css web saas


【解决方案1】:

你的代码有一点错误。

此代码:$("p").addClass(".text-change")

你能改吗:$("p").addClass("text-change")

此处示例:https://codepen.io/yasgo/pen/MWjWyMp

【讨论】:

    猜你喜欢
    • 2011-12-01
    • 1970-01-01
    • 2011-05-26
    • 1970-01-01
    • 2013-08-11
    • 2015-04-08
    • 2016-03-09
    • 1970-01-01
    • 2018-10-13
    相关资源
    最近更新 更多