最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Hide submit button using Javascript - Stack Overflow

programmeradmin4浏览0评论

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!

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!

Share Improve this question asked May 19, 2011 at 5:13 NyxynyxNyxynyx 63.7k163 gold badges506 silver badges855 bronze badges 1
  • 2 Then use script to hide the button with submitButtonRef.style.visibility = 'hidden';, after the button is in the DOM of course (use the load event or similar). – RobG Commented May 19, 2011 at 5:20
Add a ment  | 

4 Answers 4

Reset to default 7

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)

  1. 暂无评论