If you are in Chrome, newer versions of Internet Explorer or really any other modern browser this will not be a problem. But often I have clients that use old versions of browsers for various valid business needs.
To get around this problem I just capture the click event in jquery and return false. The HTML and JQuery example below shows a snippet on how to do this.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DocType html> | |
<html> | |
<head></head> | |
<body> | |
<div id="create-div"> | |
<form method="Post"> | |
<button id="cancel-button">Cancel</button> | |
</form> | |
</div> | |
</body> | |
<script type="text/javascript"> | |
$(function(){ | |
$("#cancel-button").click(function(){ | |
$("#create-div").hide(); // hide the div | |
return false; // return false to not submit the form | |
}) | |
}); | |
</script> | |
</html> |
No comments:
Post a Comment