第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何簡化下面的Script,讓寫HTML更容易?

如何簡化下面的Script,讓寫HTML更容易?

手掌心 2021-11-04 15:11:00
我使用以下代碼在選擇之間切換。但是我使用的腳本很簡單,所以我需要在 HTML 中編寫更多內容來隱藏其他選項卡,正如您在代碼中看到的那樣。幫助我使用腳本來簡化 HTML 部分。function showStuff(id) {  var id1 = id.replace(/[^\w\s]/gi, '');  document.getElementById(id).style.display = "block";  document.getElementById(id1).classList.add('active');}function hideStuff(id) {  var id1 = id.replace(/[^\w\s]/gi, '');  document.getElementById(id).style.display = "none";  document.getElementById(id1).classList.remove('active');}div.container {  padding: 7px;  height: 100%;  width: 80%;  margin: 0 auto;}<body>  <div class="container">    <ol>      <li id="tabs1" onclick="showStuff('tabs-1'); hideStuff('tabs-2'); hideStuff('tabs-3');hideStuff('tabs-4'); hideStuff('tabs-5');hideStuff('tabs-6'); hideStuff('tabs-7');hideStuff('tabs-8'); hideStuff('tabs-9');hideStuff('tabs-10'); hideStuff('tabs-11');hideStuff('tabs-12'); hideStuff('tabs-13');hideStuff('tabs-14'); hideStuff('tabs-15');hideStuff('tabs-16');hideStuff('tabs-17');hideStuff('tabs-18');hideStuff('tabs-19');">selet A</li>      <li id="tabs2" onclick="hideStuff('tabs-1'); showStuff('tabs-2'); hideStuff('tabs-3');hideStuff('tabs-4'); hideStuff('tabs-5');hideStuff('tabs-6'); hideStuff('tabs-7');hideStuff('tabs-8'); hideStuff('tabs-9');hideStuff('tabs-10'); hideStuff('tabs-11');hideStuff('tabs-12'); hideStuff('tabs-13');hideStuff('tabs-14'); hideStuff('tabs-15');hideStuff('tabs-16');hideStuff('tabs-17');hideStuff('tabs-18');hideStuff('tabs-19');">select B</li>    </ol>  </div>  <div style="display: table-cell; width: 1%; "></div>  <div id="tabs-1">    <h1>A is selected</h1>    <textarea onclick="this.focus(); this.select();" readonly="readonly">this is example and A is selected</textarea>  </div>  <div id="tabs-2" style="display : none">    <h1>B is selected:</h1>    <textarea onclick="this.focus();this.select()" readonly="readonly">Another example for b is selected</textarea></div></body>此外,我需要從文本文件(存儲在服務器中)或通過任何其他方式獲取 textarea 內容,以便我可以避免在代碼中添加冗長的部分。有沒有辦法用文本文件替換textarea?
查看完整描述

1 回答

?
白衣染霜花

TA貢獻1796條經驗 獲得超10個贊

對于顯示和隱藏,您可以使用相同的功能隱藏和取消隱藏。


假設你有:


<ol>

    <li id="tabs1" class="tabheader" onclick="setActive()" data-id="tab1">selet A</li>

    <li id="tabs2" class="tabheader" onclick="setActive()" data-id="tab2">select B</li>

</ol>

<div id="tab1" class="tabcontent">

<!--Your content-->

</div>

<div id="tab2" class="tabcontent">

<!--Your content-->

</div>

您可以使用以下 jquery 代碼:


$(".tabheader").click(function(){

    $(".tabcontent").hide();

    $("#"+$(this).data("id")).show();

});

要從文件服務器端寫入 textarea,您可以使用 PHP 或任何其他讀取文件并放入 textarea 的語言。為此,您可以使用文件讀取功能并在 textarea 之間調用它。


查看完整回答
反對 回復 2021-11-04
  • 1 回答
  • 0 關注
  • 170 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號