visible selector in jQuery with example
Visible selector returns all visible elements, elements that are not hidden.
Example :
<html>
<head>
<title>visible 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 () {
$("p:visible").css({ 'background-color': 'Orange', 'font-size': '20px' });
});
});
</script>
</head>
<body>
<p id="hiddenP">This is paragraph element.</p>
<button id="myButton">Click Me</button>
</body>
</html>
Demo :
In the above example, we have used visible selector. Visible selector return all elements that are not hidden. In the above example the visible selector selects the p element and applies CSS to it.
0 comments:
Post a Comment