首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ToggleClass没有调整段落fontSize的大小

ToggleClass没有调整段落fontSize的大小
EN

Stack Overflow用户
提问于 2012-08-08 13:39:53
回答 2查看 101关注 0票数 0

我很难让jQuery的ToggleClass增加和减少我的'p‘字体大小。单击“增加”图标时,我希望我的段落文本“fontSize”中的“id=#text”增加16 to,当再次单击该图标时,将返回14 to。我认为实现这一目标的最佳方法是使用jQuery的ToggleClass,但它似乎没有正常工作。欢迎并感谢任何建议或解决方案。

jQuery代码:

代码语言:javascript
复制
$(function(){
  $(".large-type").live("click",function(){
    $("#text").toggleClass("large");
  });
});

HTML5代码:

代码语言:javascript
复制
<p id="text">
    MANHATTAN, KAN - The Longhorns, three games into their defense of the No. 1 ranking, come to  a place where the opponent is formidable, the crowd is raucous, and the reference might just wear out their whistles.<br><br> They come to face No. 13 Kansas State, an in-your-face team that reflects the personality of its coach, Frank Martin. The wildcats spend much of their games fouling and shooting free throws.<br><br>All 12,528 tickets have been sold, and coach Rick Barnes hopes the Longhorns can summon the fortitude Texas A&M showed in the packed Erwin Center on Saturday during a 72-67 loss to the Longhorns in overtime.<br><br>"It's gonna be flipped Monday," Barnes said. "We're not gonna have the house. I hope we go in with the same intensity A&M brought."<br><br>Kansas State has 13 consecutive victories at home, its longest streak in Manhattan since winning 20 straight in 1981-82.<br><br>The Longhoorns and Wildcats would not be called rivals, but you couldn't tell by their games in recent seasons.<br><br>Barnes is 8-4 against Kansas State. The Longhorns have won four of the last six, but five of those games were decided by four points or fewer. Texas has won the last two in Manhattan. K-State has a two-game winning steak in Austin.
</p>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-08-08 13:53:06

在css中定义以下内容可以解决您的问题。

代码语言:javascript
复制
#text { font-size:14px}
#text.large{ font-size:16px}
票数 1
EN

Stack Overflow用户

发布于 2012-08-08 13:42:53

类与CSS属性值不同。因此,您需要在CSS中为“大型”类定义字体大小属性,这样才能工作:

代码语言:javascript
复制
.large{font-size: large;}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11865792

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档