<address id="ttjl9"></address>

      <noframes id="ttjl9"><address id="ttjl9"><nobr id="ttjl9"></nobr></address>
      <form id="ttjl9"></form>
        <em id="ttjl9"><span id="ttjl9"></span></em>
        <address id="ttjl9"></address>

          <noframes id="ttjl9"><form id="ttjl9"></form>

          首頁

          JSTree 默認展開 樹節點默認展開

          前端達人

          紅色部分

           

                                        $("#jstree_demo")

                                         .jstree({                                 

                                             "core" : {

                                                 "animation" : 0,

                                                 "check_callback" : true,

                                                 'force_text' : true,

                                                 "themes" : { "stripes" : true },

                                         // so that create works

                                             "check_callback" : true,

                                             'data' : function (obj, callback) {

                                                          var jsonstr="[]";

                                                          var jsonarray = eval('('+jsonstr+')');

                                                          

                                                          $.ajax({

                                                              type: "POST",

                                                              url:url,

                                                              dataType:"json",

                                                              async: false,

                                                              success:function(result) {

                                                      

                                                                

                                                                  var arrays= result;

                                                        

                                                                  for(var i=0 ; i<arrays.length; i++){

                                                                   console.log(Object.getOwnPropertyNames(arrays[i]).sort());

                                                                      var arr = {

                                                                              "id":arrays[i].id,

                                                                              "parent":arrays[i].pid==""?"#":arrays[i].pid,

                                                                              "text":arrays[i].name,

                                                                              "type":arrays[i].iconSkin,

                                                                              "state": {"opened" : true}

                                                                              //"state": {"selected":true}

                                                                      }

                                                                      jsonarray.push(arr);

                                                                  }

                                                              }

           

                                                          });

                                                          

                                                          callback.call(this, jsonarray);

                                                      }

                                                  },

                                                   

                                                  "plugins" : [ "search""state""types""wholerow","checkbox" ]

                                              });








          藍藍設計建立了UI設計分享群,每天會分享國內外的一些優秀設計,如果有興趣的話,可以進入一起成長學習,請掃碼藍小助,報下信息,藍小助會請您入群。歡迎您加入噢~~希望得到建議咨詢、商務合作,也請與我們聯系。

          截屏2021-05-13 上午11.41.03.png


          分享此文一切功德,皆悉回向給文章原作者及眾讀者.

          免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。

          藍藍設計www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 平面設計服務

          解決火狐瀏覽隱藏不了滾動條問題

          前端達人

          解決火狐瀏覽隱藏不了滾動條問題

          1.里層容器的width多17px,外層容器溢出隱藏,能兼容各個瀏覽器

          1
          2
          3
          4
          5
          6
          7
          8
          9
          10
          11
          .outContainer {
          width:350px;
          height:300px;
          overflow: hidden;
          }
          .inContainer {
             height:300px;
             width: 367px;
             overflow-x:hidden;
             overflow-y:scroll;
          }

          2.設置 scrollbar-width: none,可兼容

          1
          2
          3
          4
          5
          6
          7
          8
          9
          10
          11
          12
          13
          14
          15
          16
          17
          18
          19
          20
          21
          22
          23
          24
          .outContainer {
          width:350px;
          height:300px;
          overflow: hidden;
          }
          .inContainer {
             height:300px;
             width: 350px;
             overflow-x:hidden;
             overflow-y:scroll;
             scrollbar-width: none; 
          }
          /* 使用偽類選擇器 ::-webkit-scrollbar ,兼容chrome和safari瀏覽器 */
          .inContainer::-webkit-scrollbar{
              display: none;
          }
          /*兼容火狐*/
          .inContainer {
             scrollbar-width: none;
          }
          /* 兼容IE10+ */
          .inContainer {
              -ms-overflow-style: none;
          }

          html如下

          1
          2
          3
          4
          5
          6
          7
          8
          9
          <body>
              <div class="outContainer" >
                  <div class="inContainer">
                      <div class="inContent" ></div>
                      <div class="inContent inContent2"></div>
                      <div class="inContent" ></div>
                  </div>
              </div>
          </body>


          藍藍設計建立了UI設計分享群,每天會分享國內外的一些優秀設計,如果有興趣的話,可以進入一起成長學習,請掃碼藍小助,報下信息,藍小助會請您入群。歡迎您加入噢~~希望得到建議咨詢、商務合作,也請與我們聯系。

          截屏2021-05-13 上午11.41.03.png


          分享此文一切功德,皆悉回向給文章原作者及眾讀者.

          免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。

          藍藍設計www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 、平面設計服務

          jquery DataTable 漢化 以及其他實用配置

          前端達人

          一、將 DataTable 設置成中文

          復制代碼
          <script> $('#datatable').DataTable({
          
             language: { "sProcessing": "處理中...", "sLengthMenu": "顯示 _MENU_ 項結果", "sZeroRecords": "沒有匹配結果", "sInfo": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項", "sInfoEmpty": "顯示第 0 至 0 項結果,共 0 項", "sInfoFiltered": "(由 _MAX_ 項結果過濾)", "sInfoPostFix": "", "sSearch": "搜索:", "sUrl": "", "sEmptyTable": "表中數據為空", "sLoadingRecords": "載入中...", "sInfoThousands": ",", "oPaginate": { "sFirst": "首頁", "sPrevious": "上頁", "sNext": "下頁", "sLast": "末頁" }, "oAria": { "sSortAscending": ": 以升序排列此列", "sSortDescending": ": 以降序排列此列" }
             }
          });
          }); </script>
          復制代碼

           

          二、設置列寬度

          復制代碼
          <script>
          $('#datatable').DataTable({

          "columnDefs": [
            {
              render: function (data, type, full, meta) {
                  return "<div style='white-space:nowrap;float:right'>" + data + "</div>";
              },
              targets: [2,3,4,5,6]
            },
          ],

          });

          </script>
          復制代碼

           

          三、修改表格數據后,靜態刷新表格數據不跳轉

          dataTable.ajax.reload(null, false);

           

          // 重載所有接口數據,返回到第一頁
          dataTable.ajax.reload();

           

          相關 API

          ajax.reload( callback, resetPaging )


          里面有二個參數:
          callback :當服務器返回數據并重繪完畢時執行此回調方法,回調方法返回的是服務器返回的數據
          resetPaging: 重置(默認或者設置為true)或者保持分頁信息(設置為false) 


          藍藍設計建立了UI設計分享群,每天會分享國內外的一些優秀設計,如果有興趣的話,可以進入一起成長學習,請掃碼藍小助,報下信息,藍小助會請您入群。歡迎您加入噢~~希望得到建議咨詢、商務合作,也請與我們聯系。

          截屏2021-05-13 上午11.41.03.png


          分享此文一切功德,皆悉回向給文章原作者及眾讀者.

          免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。

          藍藍設計www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 平面設計服務

          JqueryTable的使用

          前端達人

          1.目的

          用漂亮的前端表格直觀顯示數據

           

          2. JqueryTable簡介

          JqueryTable官網

          表格顯示

           

          3.用法

          1.初始化html頁面

          設置一個table

          
          
          1. <table id="table_id" class="display">
          2. <thead>
          3. <tr>
          4. <th>Column 1</th>
          5. <th>Column 2</th>
          6. </tr>
          7. </thead>
          8. <tbody>
          9. <tr>
          10. <td>Row 1 Data 1</td>
          11. <td>Row 1 Data 2</td>
          12. </tr>
          13. <tr>
          14. <td>Row 2 Data 1</td>
          15. <td>Row 2 Data 2</td>
          16. </tr>
          17. </tbody>
          18. </table>

           

          2.引入靜態資源

          這個是JqueryTable必要的靜態資源

          
          
          1. <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.css">
          2. <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>

          如果你使用了js, 那么還需要引入jquery.js

           

          3.初始化表格

          
          
          1. $(document).ready( function () {
          2. $('#table_id').DataTable();
          3. } );

          3.實例

           

          1. html頁面

          
          
          1. <table id="tbl_grantedCoach" class="table table-striped table-bordered nowrap" style="table-layout:fixed; text-align: center;">
          2. <thead>
          3. <tr>
          4. <th width="10%">用戶名</th>
          5. <th width="10%">姓名</th>
          6. <th width="8%">性別</th>
          7. <th width="10%">手機號</th>
          8. <th width="5%">工作年限</th>
          9. <th width="12%">教員類型</th>
          10. <th width="15%">角色</th>
          11. <th width="10%">備注</th>
          12. <th width="12%">操作</th>
          13. </tr>
          14. </thead>
          15. </table>

           

          2.js代碼

          ajax 發送請求, 接受表格數據,再填寫進去

          
          
          1. initGrantedCoachGrid:function(){
          2. selectedUserId =[];
          3. if(grantedCoachGrid){
          4. grantedCoachGrid.ajax.url(
          5. "course/getGrantedCoachByFolder?json&folderId="
          6. + selectNodeId + "").load();
          7. } else {
          8. grantedCoachGrid = $('#tbl_grantedCoach')
          9. .DataTable(
          10. {
          11. "lengthMenu" : [ [ 10, 20, 30 ],
          12. [ 10, 20, 30 ] // change per page
          13. // values here
          14. ],
          15. "ordering":false,
          16. "retrieve":true ,
          17. "bDestory" :true,
          18. "pageLength": 10,
          19. "bAutoWidth" : false,
          20. "ajax" : {
          21. "url" : "course/getGrantedCoachByFolder?json&folderId="
          22. + selectNodeId + "",
          23. "type" : "get",
          24. "cache" : false,
          25. "contentType" : "application/json; charset=utf-8",
          26. "dataSrc" : ""
          27. },
          28. "rowCallback" : function(row, data) {
          29. selectedUserId.push(data.userId);
          30. },
          31. "aoColumnDefs" : [ {
          32. sDefaultContent : '',
          33. aTargets : [ '_all' ]
          34. } ],
          35. // 填入列數據
          36. "columns" : [
          37. {
          38. "data" : "loginName"
          39. },
          40. {
          41. "data" : "userFullName"
          42. },
          43. {
          44. "data" : "gender",
          45. "mRender" : function(data,
          46. type, full) {
          47. if (data == "M") {
          48. return "男";
          49. } else if (data == "F") {
          50. return "女";
          51. }
          52. }
          53. },
          54. {
          55. "data" : "mobilePhone"
          56. },
          57. {
          58. "data" : "workYear"
          59. },
          60. { "data": "coachType" , "mRender":function(data,type,full){
          61. if(data=="0")
          62. {
          63. data="理論培訓";
          64. }else if(data=="1"){
          65. data="實習培訓";
          66. }else{
          67. data="理論培訓+實習培訓";
          68. }
          69. return data;
          70. }},
          71. {
          72. "data" :function( row, type, val, meta ){
          73. return row.userRoles[0].roleName;
          74. }
          75. },
          76. {
          77. "data" : "remark"
          78. },
          79. {
          80. "data" : null,
          81. "mRender" : function(data,
          82. type, full) {
          83. return "";
          84. }
          85. }
          86. ],
          87. "oLanguage" : {
          88. "sProcessing" : "正在加載中......",
          89. "sLengthMenu" : "每頁顯示_MENU_條記錄",
          90. "sZeroRecords" : "對不起,查詢不到相關數據!",
          91. "sEmptyTable" : "無數據存在!",
          92. "sInfo" : "當前顯示_START_到_END_條,共_TOTAL_條記錄",
          93. "sInfoFiltered" : "數據表中共為 _MAX_ 條記錄",
          94. "sSearch" : "",
          95. "oPaginate" : {
          96. "sFirst" : "首頁",
          97. "sPrevious" : "上一頁",
          98. "sNext" : "下一頁",
          99. "sLast" : "末頁"
          100. }
          101. }, // 多語言配置
          102. "stateSave" : true
          103. // save the state of a table
          104. });
          105. }
          106. }

          藍藍設計建立了UI設計分享群,每天會分享國內外的一些優秀設計,如果有興趣的話,可以進入一起成長學習,請掃碼藍小助,報下信息,藍小助會請您入群。歡迎您加入噢~~希望得到建議咨詢、商務合作,也請與我們聯系。

          截屏2021-05-13 上午11.41.03.png


          分享此文一切功德,皆悉回向給文章原作者及眾讀者.

          免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。

          藍藍設計www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 平面設計服務

          JS獲取元素屬性和自定義屬性

          前端達人

          獲取元素的屬性分為兩種類型:


          1-獲取元素常見的屬性(class,id,type,value…)

          2-獲取自定義的元素的屬性(data-value,data-mess…)


          獲取元素的屬性,設置元素的屬性:

          1-原生JS

           設置屬性 .setAttribute("屬性","值") 獲取屬性 .getAttribute("屬性") 
          
          • 1
          • 2

          2-jquery

           設置屬性 .attr("屬性","值") 獲取屬性 .attr("屬性") 
          
          • 1
          • 2

          下面通過一個例子介紹一下,如何獲取和設置元素的屬性;

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>獲取元素屬性</title> <style> * { margin:0; padding:0; list-style:none; } </style> </head> <body> <div id="mayouchen"> <div style="background:red;height:20px">元素屬性獲取</div> <div class="test1"> <p id="demo">點擊按鈕來設置按鈕的 type,id,class 屬性。</p> <input value="OK" class="mayouchen"> <button onclick="mayouchen1()">獲取元素屬性</button> </div> <div style="background:green;height:20px">自定義屬性獲取</div> <div class="test2"> <div id="tree" data-leaves="47" data-plant-height="2.4m">我是被獲取的元素</div> <button onclick="mayouchen2()">獲取自定義元素屬性</button> </div> </div> <script src="https://cdn.bootcss.com/jquery/1.8.3/jquery.min.js"></script> <script> $(function() { }); function mayouchen1() { document.getElementsByTagName("INPUT")[0].setAttribute("type", "button"); document.getElementsByTagName("INPUT")[0].setAttribute("class", "mayouchen"); document.getElementsByTagName("INPUT")[0].setAttribute("id", "test1"); document.getElementsByTagName("INPUT")[0].getAttribute("id"); document.getElementsByTagName("INPUT")[0].getAttribute("class"); console.log("id=====" + document.getElementsByTagName("INPUT")[0].getAttribute("id")); console.log("class=====" + document.getElementsByTagName("INPUT")[0].getAttribute("class")); } function mayouchen2() { var tree = document.getElementById("tree"); //getAttribute()取值屬性 console.log("data-leaves======" + tree.getAttribute("data-leaves")); console.log("data-plant-height===============" + tree.getAttribute("data-plant-height")); //setAttribute()賦值屬性 tree.setAttribute("data-come", "49"); //data-前綴屬性可以在JS中通過dataset取值,更加方便 console.log("通過dataset獲得data-leaves====" + tree.dataset.leaves); console.log("通過dataset獲得data-plant-height====" + tree.dataset.plantHeight); //注意在這里連字符的訪問時,屬性要寫成駝峰形式 } </script> </body> </html> 
          
          • 1
          • 2
          • 3
          • 4
          • 5
          • 6
          • 7
          • 8
          • 9
          • 10
          • 11
          • 12
          • 13
          • 14
          • 15
          • 16
          • 17
          • 18
          • 19
          • 20
          • 21
          • 22
          • 23
          • 24
          • 25
          • 26
          • 27
          • 28
          • 29
          • 30
          • 31
          • 32
          • 33
          • 34
          • 35
          • 36
          • 37
          • 38
          • 39
          • 40
          • 41
          • 42
          • 43
          • 44
          • 45
          • 46
          • 47
          • 48
          • 49
          • 50
          • 51
          • 52
          • 53
          • 54
          • 55
          • 56
          • 57
          • 58
          • 59
          • 60
          • 61
          • 62
          • 63
          • 64
          • 65
          • 66

          上面有兩個test, test1是測試元素常見屬性,test2是測試元素自定義屬性



          藍藍設計建立了UI設計分享群,每天會分享國內外的一些優秀設計,如果有興趣的話,可以進入一起成長學習,請掃碼藍小助,報下信息,藍小助會請您入群。歡迎您加入噢~~希望得到建議咨詢、商務合作,也請與我們聯系。

          截屏2021-05-13 上午11.41.03.png


          轉自:csdn
          分享此文一切功德,皆悉回向給文章原作者及眾讀者.

          免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。

          藍藍設計www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 平面設計服務

          js和jquery給iframe src賦值的3種方法

          前端達人

          網頁使用iframe嵌入網頁時,有時候需要動態處理src的值,而不是寫死的,所以我們需要知道如何給iframe src賦值,通常是使用js或jquery來實現。本文介紹js和jquery給iframe src賦值的3種方法。

          方法一

          這是最常用的js給iframe src賦值的方法,代碼如下:

          復制代碼
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>iframe src賦值的方法</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <iframe frameborder="1" id="barframe" ></iframe> </body> </html> <script type="text/javascript"> document.getElementById("barframe").src = "http://localhost/EXAMPLE/iframe/example.html"; </script>
          復制代碼

           

          方法二

          通過js創建一個iframe元素,然后再給該元素src賦值,代碼如下:

          復制代碼
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>iframe src賦值的方法</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> </body> </html> <script type="text/javascript"> var myIframe = document.createElement('iframe');
          myIframe.src = 'http://localhost/EXAMPLE/iframe/example.html';
          document.body.appendChild(myIframe); </script>
          復制代碼

           

          最后一句 document.body.appendChild(myIframe); 是表示在 body 里添加剛定義的 myIframe 這個控件。

          我們也可以把該iframe添加到某一個div容器里,寫法如下:document.getElementById("div1").appendChild(myIframe); , div1是該div容器的id 。

          方法三

          上面兩個方法都是用js來實現的,其實我們也可以用jquery來實現,代碼如下:

          復制代碼
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>iframe src賦值的方法</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="http://www.webkaka.com/script/jquery-1.4.2.min.js" type="text/javascript"></script> <script> $(document).ready(function() {
            $('#barframe').attr('src', 'http://localhost/EXAMPLE/iframe/example.html');
          }); </script> </head> <body> <iframe frameborder="1" id="barframe"></iframe> </body> </html>
          復制代碼

          特別注意,上述jquery代碼不能缺少 $(document).ready(); ,否則iframe src賦值失敗,除非把jquery的代碼放在 <iframe ... 的html代碼后面。此外,還需要在 <head></head> 里引用 jquery.js 文件








          藍藍設計建立了UI設計分享群,每天會分享國內外的一些優秀設計,如果有興趣的話,可以進入一起成長學習,請掃碼藍小助,報下信息,藍小助會請您入群。歡迎您加入噢~~希望得到建議咨詢、商務合作,也請與我們聯系。

          截屏2021-05-13 上午11.41.03.png


          轉自:博客園
          分享此文一切功德,皆悉回向給文章原作者及眾讀者.

          免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。

          藍藍設計www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 、平面設計服務

          不錯的點擊li標簽刪除的例子

          前端達人

          <script type="text/javascript">
          function delElement(obj){
            obj.parentNode.removeChild(obj);
          }
          </script>
          <ul>
          <li onclick='delElement(this)'>1111</li>
          <li onclick='delElement(this)'>1111</li>
          <li onclick='delElement(this)'>1111</li>
          <li onclick='delElement(this)'>1111</li>
          <li onclick='delElement(this)'>1111</li>
          <li onclick='delElement(this)'>1111</li>
          </ul>




          藍藍設計建立了UI設計分享群,每天會分享國內外的一些優秀設計,如果有興趣的話,可以進入一起成長學習,請掃碼藍小助,報下信息,藍小助會請您入群。歡迎您加入噢~~希望得到建議咨詢、商務合作,也請與我們聯系。

          截屏2021-05-13 上午11.41.03.png


          轉自:博客園
          分享此文一切功德,皆悉回向給文章原作者及眾讀者.

          免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。

          藍藍設計www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 、平面設計服務

          js動態添加li,你添加的li具有你綁定的事件

          前端達人


          <%@page import="java.util.ArrayList"%>
          <%@ page language="java" contentType="text/html; charset=UTF-8"
           pageEncoding="UTF-8"%>
          <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
          <html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
          <title>Insert title here</title>
           <script type="text/javascript" src="http://www.daimajiayuan.com/download/jquery/jquery-1.10.2.min.js"></script>
           <!-- 3.0 -->
           <link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="external nofollow" rel="stylesheet">
          </head>
          <body>
          <ul id="listproject" class="list-group">
                  <script type="text/javascript">          
                  var JSarray = new Array();
                  JSarray[0] = "array0";
                  JSarray[1] = "array1";
                  JSarray[2] = "array2";
                  JSarray[3] = "array3";
                  JSarray[4] = "array4";
                   
                  for(var i = 0;i<5;i++){
                      $("#listproject").append("<li id=li"+i+">"+JSarray[i]+"</li>"); //在ul標簽上動態添加li標簽
                      $("#li"+i).attr("class",'list-group-item');     //為li標簽添加class屬性
                  }
                  $('li').on('click',function(){      //綁定事件
                   alert("事件綁定成功!");
                  });
              </script>
          </body>
          </html>
          耐得住寂寞,才能登得頂


          藍藍設計建立了UI設計分享群,每天會分享國內外的一些優秀設計,如果有興趣的話,可以進入一起成長學習,請掃碼藍小助,報下信息,藍小助會請您入群。歡迎您加入噢~~希望得到建議咨詢、商務合作,也請與我們聯系。

          截屏2021-05-13 上午11.41.03.png

          分享此文一切功德,皆悉回向給文章原作者及眾讀者.

          免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。

          藍藍設計www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 、平面設計服務

          用 JavaScript + HTML + CSS 實現選項卡操作,點擊不同選項就顯示出不同的標題欄(并實現其他要求操作)

          前端達人

          Ⅰ、問題描述:

          1、用JavaScript + html + css 實現,選項卡操作;
          2、分析:
          A、用 html + css 實現布局(盒子的布置,空間的分配等);
          B、用 JavaScript 中的 DOM 操作,實現點擊不同選項顯示不同標題欄的功能;

          Ⅱ、實現過程如下:

          1、運行軟件VScode,親測可實現;
          2、運行代碼:

          <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> * { margin: 0; padding: 0; font-family: '微軟雅黑'; font-size: 14px; } #container { width: 398px; margin: 100px auto; } #container a { display: block; width: 98px; height: 42px; line-height: 42px; text-align: center; float: left; border-top: solid 1px #ff4400; border-bottom: solid 1px #ff4400; border-left: solid 1px #ff4400; color: #333333; text-decoration: none; } #container a:hover { /* 鼠標放在 a 的標簽上,其文字將顯示為:紅色; */ color: #ff4400; } .content { width: 355px; height: 140px; text-align: center; border-right: solid 1px #ff4400; border-bottom: solid 1px #ff4400; border-left: solid 1px #ff4400; padding: 30px 0 0 40px; display: none; } .clear { clear: left; } #container a.on { /* 對a標簽中的類名為:on 的標簽進行操作; */ background: #ff4400; color: #fff; } </style> </head> <body> <div id="container"> <a href="#" class="on" >充話費</a> <!-- 類為:on 的 a 標簽; --> <a href="#" >充流量</a> <a href="#" >充固話</a> <a href="#" style="border-right: 1px solid #ff4400;">充寬帶</a> <!-- style 操作目的:使得顯示的盒子最右邊有邊框; --> <div class="clear"></div> <div class="content" style="display: block;"> <!-- style 操作目的:使第一個圖片在初始狀態時,能顯示出來; --> <img src="images/1.png" width="355px"/> <!-- 該位置存放的是:圖片的地址 (即:里面加載的是圖片信息) --> </div> <div class="content"> <img src="images/2.png" width="355px" /> <!-- 該位置存放的是:圖片的地址 (即:里面加載的是圖片信息) --> </div> <div class="content"> <img src="images/3.png" width="355px" /> <!-- 該位置存放的是:圖片的地址 (即:里面加載的是圖片信息) --> </div> <div class="content"> <img src="images/4.png" width="355px" /> <!-- 該位置存放的是:圖片的地址 (即:里面加載的是圖片信息) --> </div> </div> <script> var as = document.getElementsByTagName('a'); //通過 DOM 操作,拿到標簽為 a 的所有的元素(是個集合); var divs = document.getElementsByClassName('content');//通過 DOM 操作,拿到類為 content 的所有的元素(是個集合); for(var i=0; i<as.length; i++) { as[i].index = i; //給拿到的每個元素對象添加索引屬性; (由于通過 DOM 操作拿到的元素是對象,因此可以添加屬性值); as[i].onclick = function() { //給 as集合 綁定單擊事件; for(var j=0; j<as.length; j++) { as[j].className = ''; //將 as集合 的所有元素的類名全部取消; (此時用的思想為:排他思想;) divs[j].style.display = 'none'; //將 divs集合 的所有元素全設置成不顯示狀態; } this.className = 'on'; //僅將被單擊的元素的類名設置為:on,以便執行在 css 中的相關操作; divs[this.index].style.display = 'block'; //并將被單擊的元素的相關圖片設置為:block狀態;(即:顯示出來;) } } </script> </body> </html> 
          
          • 1
          • 2
          • 3
          • 4
          • 5
          • 6
          • 7
          • 8
          • 9
          • 10
          • 11
          • 12
          • 13
          • 14
          • 15
          • 16
          • 17
          • 18
          • 19
          • 20
          • 21
          • 22
          • 23
          • 24
          • 25
          • 26
          • 27
          • 28
          • 29
          • 30
          • 31
          • 32
          • 33
          • 34
          • 35
          • 36
          • 37
          • 38
          • 39
          • 40
          • 41
          • 42
          • 43
          • 44
          • 45
          • 46
          • 47
          • 48
          • 49
          • 50
          • 51
          • 52
          • 53
          • 54
          • 55
          • 56
          • 57
          • 58
          • 59
          • 60
          • 61
          • 62
          • 63
          • 64
          • 65
          • 66
          • 67
          • 68
          • 69
          • 70
          • 71
          • 72
          • 73
          • 74
          • 75
          • 76
          • 77
          • 78
          • 79
          • 80
          • 81
          • 82
          • 83
          • 84
          • 85
          • 86
          • 87
          • 88
          • 89
          • 90
          • 91
          • 92
          • 93
          • 94
          • 95
          • 96
          • 97
          • 98
          • 99
          • 100
          • 101
          • 102
          • 103
          • 104

          3、結果展示:
          A、默認的顯示結果:
          在這里插入圖片描述
          B、點擊 ‘充流量’ 后的顯示結果:
          在這里插入圖片描述
          C、點擊 ‘充固話’ 后的顯示結果:
          在這里插入圖片描述

          D、點擊 ‘充寬帶’ 后的顯示結果:
          在這里插入圖片描述
          4、可能存在的問題:
          A 、如果自己也加載了圖片信息,仍然不能顯示該結果,可以直接下載我傳上去的文檔(可能解釋的更詳細),可以直接在 VScode 等其他軟件上加載運行;

          地址為:

          https://download.csdn.net/download/weixin_43405300/19645922?spm=1001.2014.3001.5501

          Ⅲ、小結:

          哪里有不對或不合適的地方,還請大佬們多多指點和交流!


          https://download.csdn.net/download/weixin_43405300/19645922?spm=1001.2014.3001.5501





          藍藍設計建立了UI設計分享群,每天會分享國內外的一些優秀設計,如果有興趣的話,可以進入一起成長學習,請掃碼藍小助,報下信息,藍小助會請您入群。歡迎您加入噢~~希望得到建議咨詢、商務合作,也請與我們聯系。

          截屏2021-05-13 上午11.41.03.png


          轉自:csdn
          分享此文一切功德,皆悉回向給文章原作者及眾讀者.

          免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。

          藍藍設計www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 、平面設計服務

          關于通過v-if渲染的element-ui表單,校驗規則不生效的問題

          前端達人

          記錄關于通過v-if渲染的element-ui表單,校驗規則不生效的問題

          代碼

           <el-form ref="form" :model="form" :rules="rules" label-width="124px"> <template v-if="show1"> <el-form-item label="標題1" prop="requestType"> <el-input size="mini" v-model="form.requestType" /> </el-form-item> </template> <template v-if="show2"> <el-form-item label="標題2" prop="requestData"> <el-input size="mini" v-model="form.requestData" /> </el-form-item> </template> </el-form> 
          
          • 1
          • 2
          • 3
          • 4
          • 5
          • 6
          • 7
          • 8
          • 9
          • 10
          • 11
          • 12

          原因:
          因為form-item綁定驗證事件是在mounted中進行的,規則變化后沒有進行重新綁定驗證事件,v-if渲染組件節點diff后被復用了,所以驗證也就自然失效了

          參考回答:v-if案例解析(element-ui form-item 結合 v-if 動態生成rule規則\表單元素,表單無法驗證問題剖析 )
          感興趣的小伙伴可以學習一下

          解決方案:

          1. 給每一個el-form-item添加一個key屬性區分
           <el-form ref="form" :model="form" :rules="rules" label-width="124px"> <template v-if="show1"> <el-form-item label="標題1" prop="requestType"> <el-input size="mini" v-model="form.requestType" /> </el-form-item> </template> <template v-if="show2"> <el-form-item key="1" label="標題2" prop="requestData"> <el-input size="mini" v-model="form.requestData" /> </el-form-item> </template> </el-form> 
          
          • 1
          • 2
          • 3
          • 4
          • 5
          • 6
          • 7
          • 8
          • 9
          • 10
          • 11
          • 12

          如果v-if渲染的目標是整個表單,則在form標簽寫入key

          1. 直接在el-form-item中寫rules
           <el-form ref="form" :model="form" :rules="rules" label-width="124px"> <template v-if="show1"> <el-form-item label="標題1" prop="requestType"> <el-input size="mini" v-model="form.requestType" /> </el-form-item> </template> <template v-if="show2"> <el-form-item label="標題2" prop="requestData" :rules="{ required: true, message: 'xxx不能為空', trigger: 'blur' }"> <el-input size="mini" v-model="form.requestData" /> </el-form-item> </template> </el-form> 
          
          • 1
          • 2
          • 3
          • 4
          • 5
          • 6
          • 7
          • 8
          • 9
          • 10
          • 11
          • 12

          :rules="{ required: true, message: ‘xxx不能為空’, trigger: ‘blur’ }"

          這里需要注意JavaScript中的單引號''與雙引號""的使用規范


          還有很多方法可以解決這個問題,這里只記錄我用過的其中兩個方法。有其他解決方法的同學歡迎留言討論!

          藍藍設計建立了UI設計分享群,每天會分享國內外的一些優秀設計,如果有興趣的話,可以進入一起成長學習,請掃碼藍小助,報下信息,藍小助會請您入群。歡迎您加入噢~~希望得到建議咨詢、商務合作,也請與我們聯系。

          截屏2021-05-13 上午11.41.03.png


          轉自:csdn
          分享此文一切功德,皆悉回向給文章原作者及眾讀者.

          免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。

          藍藍設計www.syprn.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 平面設計服務

          日歷

          鏈接

          個人資料

          藍藍設計的小編 http://www.syprn.cn

          存檔

          亚洲va欧美va天堂v国产综合