prevent form submission using jquery
//option A
$("form").submit(function(e){
e.preventDefault();
});<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type='text/javascript'>
$(document).ready(function() {
//option A
$("form").submit(function(e){
alert('submit intercepted');
e.preventDefault(e);
});
});
</script>
</head>
<body>
<form action="page_url" method="GET">
Search <input type='text' name='q' />
<input type='submit'/>
</form>
</body>
</html>
Also in JavaScript:
- react fun tion
- react create array
- upload file from url javascript
- jquery on body click
- js isset
- what is adapter.js
- chrome extension get current tab url
- javascript get srollwidth
- python config file json datatypes
- include gif in react
- react native multiple touchableopacity
- how to define variable in javascript
- how to run method in method vue js on load
- simple alert program in javascript
- merge two strings with alternate characters javascript
- host angular app on node server
- Your global Angular CLI version (11.0.2) is greater than your local version
- copy php array to javascript
- arrow function in javascript
- scroll to bottom of div javascript
- javascript alert
- string pop last char js
- vuejs take rgba values from coordinate
- import modal bootstrap react