简体   繁体   English

单击第一个按钮后如何显示第二个按钮?

[英]How to display second button after the click on first button?

How to display second button after the click on first button?? 单击第一个按钮后如何显示第二个按钮?

I mean, when The user clicks on one button, he should see another button, on click of which he should return to his previous button!! 我的意思是,当用户单击一个按钮时,他应该看到另一个按钮,单击时他应该返回到先前的按钮! Cyclic event kind of... I wanted to do this using Java script and HTML. 循环事件有点...我想使用Java脚本和HTML进行此操作。

I tried to use 'onclick' but it dint work!! 我试图使用“ onclick”,但它确实有用! Help!! 救命!!

This is what I used.. 这就是我用的

    `<body>

 function alert()
{
  alert("54");
    // <input type="button" id="btnSer" value="Back"/>
}

  <input type="button" id="btnSearch" value="Search" onClick="alert();">


</body>`

Something like this? 像这样吗

<button id="button1" style="display:block;" onclick="document.getElementById('button2').style.display = 'block'; this.style.display = 'none';">Button 1</button>
<button id="button2" style="display:none;" onclick="document.getElementById('button1').style.display = 'block'; this.style.display = 'none';">Button 2</button>

here is the code using simple plain javascript : (*note that naming your function alert() isnt smart because there is already a predefined function in js called alert) 这是使用简单的普通javascript的代码:(*请注意,命名函数alert()并不明智,因为js中已经有一个预定义的函数称为alert)

Javascript Code JavaScript代码

function addBtn(){
  document.getElementById('btnHolder').innerHTML = '<input type="button" onClick="javascript:removeBtn();" value="click" />';
}

function removeBtn(){
  document.getElementById('btnHolder').innerHTML = '';
}

HTML 的HTML

<div id="btnOne"><input type="button" onClick="javascript:addBtn();" value="click" /></div>
<div id="btnHolder"></div>

this code is not tested but it should work, let me know if you have any other questions 该代码未经测试,但可以正常工作,如果还有其他问题,请告诉我

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM