Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
377 views
in Technique[技术] by (71.8m points)

javascript - 单击后隐藏按钮(hide button after its been clicked)

The issue I am having is that I want the submit button hidden after(我遇到的问题是我想在之后隐藏提交按钮)


I have chosen a date from a calendar.(我从日历中选择了一个日期。) and submitted it.(并提交。) The html/script I am using is ...(我正在使用的html / script是...) <input type="button" value="Try it" id="Submit1" onclick= "myFunction();this.form.submit();"> <script> function myFunction() { var x = document.getElementById("Submit1"); x.hidden= true; } </script> ... When you have clicked the button it hides the button for a second but then appears again.(单击按钮后,按钮会隐藏一秒钟,然后再次出现。) I guess this when the page is reloaded.(我猜这是在重新加载页面时。) Anybody have a solution for this.(任何人对此都有解决方案。) Its being written in Classic asp VB(它用Classic ASP VB编写)   ask by Iain translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

try(尝试)

var x = document.getElementById("Submit1"); x.style.visibility = "hidden"; https://www.w3schools.com/jsref/prop_style_visibility.asp(https://www.w3schools.com/jsref/prop_style_visibility.asp) But this code should be executed after reloading the page, which means that the body of the new page just needs to have code(但是此代码应在重新加载页面后执行,这意味着新页面的主体只需要有代码) <script> window.myFunction(); </script> The backend side (php, ruby, node ...) can take care of this.(后端(php,ruby,node ...)可以解决这个问题。) You can call the code from the browser console (F12, then CTRL + `).(您可以从浏览器控制台调用该代码(F12,然后按CTRL +`)。) This will give you a feel for what code you need to run and when.(这会让您感觉需要运行什么代码以及何时运行。)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...