How to use JQuary CSS Property and Value Method

This article describe about jQuary CSS Property and Value Method.
  • 1627

Set CSS Property and Value

css(name, value): This method set property and value in this program.

Syntax

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

Example

<!DOCTYPE html>

<html>

<head>

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

<script type="text/javascript">

    $(document).ready(function ()

{

        $("button").click(function ()

{

            $("p").css("background-color", "red");

        });

    });

</script>

</head>

 

<body>

<h2>This is a jQuery</h2>

<p>This is a css.</p>

<p>This is name and value.</p>

<button>Click here</button>

</body>

</html>

Output

op1.jpg

After click this button

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

© 2018 DotNetHeaven. All rights reserved.