jQuery – preview button in new tab(window), target blank
Posted on: December 21, 2011 /
Categories: JQuery
jQuery – preview button in new tab(window), target blank
<!-- DOCTYPE -->
<html>
<head>
<title>jQuery – preview button in new tab(window), target blank</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<form id="my-form" method="POST" action="">
<input type="submit" name="submit" id="submit" value="OK">
<input type="submit" name="preview" id="preview" value="Preview">
</form>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#preview').click(function(){
jQuery('#my-form').attr('target', '_blank');
});
jQuery('#submit').click(function(){
jQuery('#my-form').removeAttr('target');
});
});
</script>
</body>
</html>