<input onclick="ReadALL(this)" type="button" value="閱讀更多...." class="ReadAll"> <div class="aaa" style="display: none;"> ............ ... 內容 ... ............ </div> <style> .ReadAll{ background:#e5eecc; border: solid 3px #c3c3c3; cursor: pointer; font-size: 16px; text-align: center; width: 100% } </style> <script> function ReadALL(xx){//alert(); var x = document.querySelectorAll('.aaa'); if(xx.value == '閱讀更多....'){ xx.value ='關閉全文....' x.forEach(el => { el.style.display = 'block';}); } else { xx.value ='閱讀更多....' x.forEach(el => {el.style.display = 'none';}); } } </script>
沒有留言:
發佈留言