Articles → JQUERY → Ready Function In Jquery
Ready Function In Jquery
Prerequisite
- Hands on experience in creating HTML page.
- Basic knowledge of JavaScript.
- Basic knowledge of event handling in JavaScript.
Introduction
Syntax
$(document).ready(function() {
// Add your code here
});
Adding Events In $(Document).Ready()
<a href='#' onclick="javascript:alert('this is the click event');">Click Me</a>
$(document).ready(function() {
$('a').click(function() {
alert("you clicked me!");
});
});
Full Code
<html>
<head>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
</head>
<body>
<a href="#">Click Me</a>
<script>
$(document).ready(function () {
$("a").click(function () {
alert("You clicked me!");
});
});
</script>
</body>
</html>
Try It
Posted By - | Karan Gupta |
|
Posted On - | Monday, October 24, 2011 |