I have two div's A and B, I looking example to switch between them without reloading a page, for example onclick a first button show only div A, second button show only Div B, and third button show all A and B div's
1条回答 默认 最新
weixin_33691817 2018-06-18 05:07关注<div id="A" style="dispay:none"> <p> this is div 1 </p> </div> <div id="B" style="dispay:none"> <p> this is div 2 </p> </div> <input type="button" value="showA" onclick="showA()"> <input type="button" value="showA" onclick="showB()"> <input type="button" value="showA" onclick="showAB()"> <script> var showA = function() { document.getElementById('A').style.display = 'block'; document.getElementById('B').style.display = 'none'; } var showB = function() { document.getElementById('B').style.display = 'block'; document.getElementById('A').style.display = 'none'; } var showAB = function() { document.getElementById('A').style.display = 'block'; document.getElementById('B').style.display = 'block'; } </script>解决 无用评论 打赏 举报