2012-08-08 3 views
0

jQuery의 ToggleClass를 가져 와서 'p'글꼴 크기를 늘리거나 줄이는 데 어려움이 있습니다. 증가 아이콘을 클릭하면 내 단락 텍스트 'id = # text'의 fontSize가 16px 증가하고 아이콘을 다시 클릭하면 14px 감소합니다. 이 목표를 달성하는 가장 좋은 방법은 jQuery의 ToggleClass를 사용하는 것이지만 제대로 작동하지 않는 것 같습니다. 제안이나 해결책을 환영하며 높이 평가합니다.ToggleClass 단락의 크기를 조정하지 않습니다 fontSize

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> 
+2

CSS를 게시 할 수 있습니까? "제대로 작동하지 않는다"는 것은 무엇을 의미합니까? – karim79

답변

1

이 문제를 해결할 수 있습니다 귀하의 CSS에 다음과 같은 정의.

#text { font-size:14px} 
#text.large{ font-size:16px} 
+0

문제를 해결해 주셔서 감사합니다. –

0

클래스 CSS 속성 값과 동일하지 않습니다. 그래서 당신은 일이에 대해 "큰"클래스에 대한 귀하의 CSS에서 글꼴 크기 속성을 정의해야합니다

.large{font-size: large;} 
관련 문제