开发者

Changing font size with jquery

开发者 https://www.devze.com 2023-04-09 21:56 出处:网络
I\'m trying to change the font-size of the text in a 开发者_如何学运维textarea by using the .css attr but its not working, do you guys have any ideas?

I'm trying to change the font-size of the text in a 开发者_如何学运维textarea by using the .css attr but its not working, do you guys have any ideas?

<html>
<head>

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
function crap () {
    var text_input = $('#textarea').val();
    text_input.css("font-size", "14px");
   }
</script>
</head>
<body>

<textarea id="textarea" rows="30" cols="70"> </textarea><br/><br/>
Font size:<input type="text" id="font_size"/> <input type="button" id="px" value="14px" onClick="crap()"/>

</body>
</html>


function crap () {
    var text_input = $('#textarea');
    text_input.css("font-size", "14px");
}

Remove .val. That will get the value within the textarea, you want to affect the textarea itself.


$(document).ready(function() {

  $('#incfont').click(function(){   

        curSize= parseInt($('#content').css('font-size')) + 2;

  if(curSize<=200)

        $('#content').css('font-size', curSize);

        }); 

  $('#decfont').click(function(){   

        curSize= parseInt($('#content').css('font-size')) - 2;

  if(curSize>=12)

        $('#content').css('font-size', curSize);

        });

  $('#minheight').click(function(){   

        curSize= 16;

        $('#content').css('font-size', curSize);

        }); 

 });


Alternative:

<style type="text/css">

#textarea
{
     font-size:14px;
}

</style>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号