Hide submit button using Javascript

▼魔方 西西 提交于 2021-01-28 03:59:41

问题


How do I hide the submit button using javascript? Reason is because my form checkboxes submits the form on click but only when JS is enabled. For those with JS disabled, I want them to see the submit button, so I want to hide the submit button using JS. I'm using Codeigniter if this helps. Thanks!


回答1:


Why javascript when noscript will do the job:

<form>
.
.
.
<noscript>
<input type="submit" />
</noscript>
</form>



回答2:


simple javascript,

<body onload="hideButton()">
<script>
function hideButton()
{
    document.getElementById("buttonId").style.display='none';
    //or you can try
    //document.getElementById("buttonId").style.visibility='hidden';
}
</script>

<input type="submit" value="submit" id="buttonId" />
</body>



回答3:


In jQuery:

$(document).ready(function() {
  $('#buttonId').hide();
});




回答4:


It is very easy to hide a submit button:

<form method="post/get" action="#">
<input type="Text" name="xyz">
<input type="submit" style="visibility:hidden">
</form>


来源:https://stackoverflow.com/questions/6054081/hide-submit-button-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!