Big Data and Hadoop Training @$80 or Rs. 6,000 only - valid till Oct 17th Apply Now!

jQuery alert()

Ads
 

jQuery alert()

In an application alert boxes are used to provide information at run time. These information helps user of applications to do tasks further with more information at runtime.

In an application alert boxes are used to provide information at run time. These information helps user of applications to do tasks further with more information at runtime.

jQuery alert()

In this section we will discuss about alert box in jQuery.

In an application alert boxes are used to provide information at run time. These information helps user of applications to do tasks further with more information at runtime. Alert box can be popped up after happening an event such as click event or after completing a line of code execution. .click() function in jQuery helps in to bind the click event, JavaScript event.

Example

Here I am giving a simple example which will demonstrate you about how an alert box can display information. In this example we will display an alert box after clicking a button and the click event is generated. When a user will execute this example and click on the button then the alert box will be displayed.

jQueryAlertExample.html

<!DOCTYPE html>
<html>
<head>
<title>jQuery Alert Example</title>
<style>
p { color:red; margin:5px; cursor:pointer; }
p:hover { background:yellow; }
</style>
<script type="text/javascript" src="jquery-1.9.1.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
$("#b1").click(function(){
alert("jQuery alert box example !");
});
});
</script>
<body>
<p>Click on button</p>
<button id="b1">Click Here</button>
</body>
</html>

Output

To run the above example you will have to download the jquery-1.9.1.js file. When you will run the above example then the output will be as follows :

Download Source Code

Ads

Ads