Hints
css() function used to apply styles to an elements.
Example 1: mutiple styles applied to an element.
Syntax: $("element").css({"color":"white","font-size":"12px");
Example 2: Single styles applied to an element.
Syntax: $("element").css("color","white");
|
Example 1: mutiple styles applied to an element
<html>
<head>
<title>HTML-JQuery</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
$(function () {
$(".element").css({
"color": "red",
"font-size": "30px"
});
});
</script>
</head>
<body>
<div class="element">hello</div>
</body>
</html>
|
Demo Example : 1
|
Example 2: Single styles applied to an element
<html>
<head>
<title>HTML-JQuery</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
$(function () {
$(".element").css("color", "red");
});
</script>
</head>
<body>
<div class="element">hello</div>
</body>
</html>
|
Demo Example :2
|