jQuery Examples

There are many features, built-in functions, and effects in jQuery and millions of associated examples. Some of the simple examples of jQuery are discussed below.

Example1:

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p>Hello world</p>
<p>If you don’t like me, click me away!</p>
</body>
</html>

Example2:

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#test").hide();
});
});
</script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$("p").css("background-color", "cyan");$("p").css("color", "green")
});
</script>
</head>
<body>
<p>This is my second program.</p>
</body>
</html>