How to use JQuary CSS Method

This article describe about jQuary CSS Method.
  • 1882

css() method in jQuery

css() method is used three different syntax: css(name), css(name, value), css(properties).

css(name): only for return property value in this program.

Syntax

$(selector).css("background-color");

Example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $("div").click(function () {

            $("p").html($(this).css("background-color"));

        });

    });

</script>

</head>

 

<body>

<div style="width:80px;height:80px;background:blue"></div>

<p>Click the blue box and return the background color value.</p>

</body>

</html>

 

Output

 op1.jpg

op2.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.