Home > Article > Web Front-end > How Can I Change Text Color and Size Dynamically with jQuery?
$(this).css('color', 'red');<p>For instance, if you have the following HTML element:
<p><p>You can add the jQuery code to change its color to red on hover as follows:
$('#text').mouseover(function() { $(this).css('color', 'red'); });<p>Simultaneously Modifying Color and Size <p>It is also possible to adjust multiple CSS attributes simultaneously. To change both text color and size on hover, for example:
$(this).css({ 'color': 'red', 'font-size': '150%' });<p>General CSS Attribute Manipulation <p>The .css() jQuery function allows you to set any CSS attribute of an element. This provides great flexibility for customizing the appearance of your elements on the fly.
The above is the detailed content of How Can I Change Text Color and Size Dynamically with jQuery?. For more information, please follow other related articles on the PHP Chinese website!