开发者

How to display second button after the click on first button?

开发者 https://www.devze.com 2023-04-05 12:39 出处:网络
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!! Cy

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 Jav开发者_如何转开发a script and HTML.

I tried to use 'onclick' but it dint work!! 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 Code

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

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

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

0

精彩评论

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