如何用一個按鈕切換文本大小? 在14點和16點之間切換會很酷。
由於jQuery單鍵切換文本
實施例 '兩個按鈕沒有切換'
<!DOCTYPE html PUBLIC ">
<head>
<script type="text/javascript" src="js/jquery-1.4.min.js"></script>
<script type='text/javascript'>
$(function(){
$('input').click(function(){
var ourText = $('p');
var currFontSize = ourText.css('fontSize');
var finalNum = parseFloat(currFontSize, 10);
var stringEnding = currFontSize.slice(-2);
if(this.id == 'large') {
finalNum *= 1.2;
}
else if (this.id == 'small'){
finalNum /=1.2;
}
ourText.css('fontSize', finalNum + stringEnding);
});
});
</script>
</head>
<body>
<h2>Toggle Text jQuery Single Button? </h2>
<!--NEED A SINGLE BUTTON TOGGLE-->
<input type='button' value='< text small' id='small' />
<input type='button' value='text large>' id='large' />
<p>My Text!!!</p>
</body>
</html>