0

jQuery の ToggleClass で「p」フォント サイズを増減するのに苦労しています。増加アイコンをクリックすると、段落テキスト 'id=#text' の fontSize が 16px 増加し、アイコンが再度クリックされると 14px 減少します。この目標を達成する最善の方法は、jQuery の ToggleClass を使用することだと思いますが、正しく機能していないようです。提案や解決策は大歓迎です。

jQuery コード:

$(function(){
  $(".large-type").live("click",function(){
    $("#text").toggleClass("large");
  });
});

HTML5 コード:

<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>
4

2 に答える 2

1

cssで以下を定義すると、問題が解決する場合があります。

#text { font-size:14px}
#text.large{ font-size:16px}
于 2012-08-08T13:53:06.123 に答える
0

クラスは CSS プロパティ値と同じではありません。したがって、これを機能させるには、「大きな」クラスの CSS で font-size プロパティを定義する必要があります。

.large{font-size: large;}
于 2012-08-08T13:42:53.683 に答える