[英]How to change font-size Text with <input type= range> using Jquery
[英]How to change id font-size using jQuery .attr()?
我正在嘗試使用jQuery方法.attr()更改id的字體大小,如下所示:
$("#level-title").attr("font-size", "1rem");
這不起作用。
該ID當前正在我的外部CSS中安裝,如下所示:
#level-title {
font-family: 'Press Start 2P', cursive;
font-size: 3rem;
margin: 2%;
color: #FEF2BF;
}
如何使用jQuery適當更改其字體大小?
我的完整樣式表可以在這里看到:
https://github.com/raschmitt/simon-game/blob/master/styles.css#L17
而我的Js文件在這里:
https://github.com/raschmitt/simon-game/blob/master/game.js#L48
使用.css()
$("#level-title").css("font-size", "1rem");
要使用jQuery管理元素的樣式,您必須使用.css()
$("#level-title").css("font-size", "1rem");
雖然不是首選,但您仍然可以通過設置style屬性來使用attr()
:
$("#level-title").attr("style", "font-size: 1rem");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.