开发者

Hide submit button using Javascript

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 wan开发者_StackOverflow中文版t them to see the submit button, so I want to hide the submit button using JS. I'm using Codeigniter if this helps. Thanks!


Why javascript when noscript will do the job:

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


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>


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>


In jQuery:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜