I want to clear the alert without using the link below (class="remove") but when the user clicks anywhere in say a div on the page.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".remove").click(function(){
$("#errprompt").remove();
});
});
</script>
</head>
<body>
<div style="border-style:solid;">
<p><a class="remove" href="#">Clear Alerts</a></p>
<span id="errprompt" class="errprompt" name="firstname">* Please enter something</span>
</div>
</body>
</html>
You can use jquery.onClick() on a div object.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"> </script>
<script>
$(document).ready(function(){
$("div.clickable").click(function(){
$("#errprompt").remove();
});
});
</script>
</head>
<body>
<div style="border-style:solid;" class="clickable">
<p><a class="remove" href="#">Clear Alerts</a></p>
<span id="errprompt" class="errprompt" name="firstname">* Please enter something</span>
</div>
</body>
</html>
Not sure if it answer your question, let me know.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.