If you have any query feel free to chat us!
Happy Coding! Happy Learning!
In jQuery, the css()
method can be used to modify CSS properties of an element. The method takes two parameters - the CSS property name and the value to be set.
Here is an example that changes the background color of all paragraphs to yellow:
htmlCopy code
<!DOCTYPE html>
<html>
<head>
<title>jQuery Example</title>
<style>
p {
background-color: blue;
color: white;
padding: 10px;
}
</style>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$("p").css("background-color", "yellow");
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>
In the above example, the $(document).ready()
function is used to make sure that the script is executed only after the document has finished loading. The $
function is used to select the paragraphs, and the css()
method is used to set the background color to yellow.
You can also pass an object with multiple CSS properties and their values to the css()
method. Here is an example that sets the background color and font size of all paragraphs:
htmlCopy code
<!DOCTYPE html>
<html>
<head>
<title>jQuery Example</title>
<style>
p {
background-color: blue;
color: white;
padding: 10px;
}
</style>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$("p").css({
"background-color": "yellow",
"font-size": "20px"
});
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>
In this example, an object is passed to the css()
method with the CSS properties and their values to be set. The properties and values are separated by a colon (:
), and each property-value pair is separated by a comma.
Comments: 2
I am not able to access videos from second class and further. I have already completed first class
When will I get my course?
Now, Your query was resolved.