I want to check if I'm not using an Ipad and if so change the font size in a div #txtArea. I have the following code but it doesn't work:
<script>if ($(window).width() < 600) { $('#txtArea').attr('font-size:60px'); }</script>
What am I doing wrong?
Thanks
Font-size is style, not an attribute so you need to use css method to change it:
$('#txtArea').css('font-size', '60px');
Note that it may be better to use CSS media queries based on width instead of script code.
<style>
@media (max-width: 600px) {
#txtArea {
font-size:60px;
}
}
</style>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.