Magicmasi Magicmasi - 1 year ago 44
HTML Question

How to not to submit form in jQuery

I have a question regarding this code i was trying on my website. i wanted to minimize the size of the writing so i tried with hiding object due a simple click. But that did always submit my form.

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#hide").click(function(){
$("table").hide();
});
$("#show").click(function(){
$("table").show();
});
});
</script>
</head>
<body>


<table style="border:solid #FFFFFF 2px;
background-color:#0000ff;height:1px;width:300px;
text-align:left;" "empty-cells:hide;" border="1" cellpadding="1" cellspacing="1">
<tr>
<th>Test</th>
<th>Extras</th>
<th>Extras</th>
</tr>
</table>
<br>

<button id="hide">Hide</button>
<button id="show">Show</button>

</body>
</html>

[submit class:button id:form-submit "Send"]

Answer Source

That worked much easier withouth any further problems

> <button title="Click to show/hide content" type="button"
> onclick="if(document.getElementById('Funktionen')
> .style.display=='none') {document.getElementById('Funktionen')
> .style.display=''}else{document.getElementById('Funktionen')
> .style.display='none'}">+</button> <div id="Funktionen"
> style="display:none;">   HERE COMES IN WHATEVER YOU WANT TO HIDE WITH
> the + Button </div>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download