classclass selector in jQuery with exmaple
- classclass selector returns all the element with the specified class names.
- Using this selector we can select elements with more than one class applied.
Example 1 :
<html>
<head>
<title>Multiple Class Selector</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
<script type="text/javascript">
$(document).ready(function()
{
$("#myButton").click(function()
{
$(".myDiv1.myDiv2").css({'font-size':'20px','background-color':'Orange'});
});
});
</script>
</head>
<body>
<div class="myDiv1 myDiv2">This is div.</div>
<button id="myButton">Click Me</button>
<button onclick="location.reload()">Reset</button>
</body>
</html>
Demo :
In the above example, we have used classclass selector. ClassClass selector selects all the elements with the specified class names. In above example, it selects the div with the specifies two class names and applies CSS to it.
0 comments:
Post a Comment