javascript - jExpand.js Expandable tables -


in head have these files only:

<script src="expand.js"></script> <link href="style.css" rel="stylesheet" /> 

... expand.js has got inside:

(function ($) {     $.fn.jexpand = function () {         var element = this;         $(element).find("tr:odd").addclass("odd");         $(element).find("tr:not(.odd)").hide();         $(element).find("tr:first-child").show();         $(element).find("tr.odd").click(function () {             $(this).next("tr").toggle();         });     } })(jquery); 

and css file has got styles table:

#example_table {   border-collapse: collapse;   font-family: "lucida sans unicode","lucida grande",sans-serif;   font-size: 12px;   margin: 20px;   text-align: left;   width: 100%; } #example_table th {   color: #339;   font-size: 15px;   font-weight: normal;   padding: 12px; } #example_table td {   background-color: #e8e8e8;   border-top: 1px solid #fff;   padding: 9px 12px; } #example_table tr.odd td {   cursor:pointer; } #example_table tr:not(.odd) td {   background-color: #f4f4ff; }  .tablecontainer{   width: 90%; }  #training-box { background: none no-repeat scroll 0 0 rgba(0, 0, 0, 0); float: left; display: inline-block;}  .tableup {     margin-top: -30px;     margin-left: -20px; } 

the html:

<div class="tablecontainer ">             <table id="example_table">                 <tr>                     <th></th>                 </tr>                 <tr>                     <td class="fa fa-plus-circle">&nbsp;&nbsp;title 1</td>                     <td></td>                     <td></td>                     <td></td>                     <td></td>                 </tr>                 <tr>                     <td colspan="5">                         <!-- additional custom info here (for record 1) -->                         <hr class="micro-hr" />                         <span class="fa fa-arrow-circle-o-right">                             lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua.                          </span>                         <hr class="micro-hr" />                     </td>                 </tr>                 <tr>                     <td class="fa fa-plus-circle">&nbsp;&nbsp;title 2</td>                     <td></td>                     <td></td>                     <td></td>                     <td></td>                 </tr>                 <tr>                     <td colspan="5">                         <!-- additional custom info here (for record 2) -->                         <div class="training-box">                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet, consectetur adipiscing elit. </span><br>                             <hr class="micro-hr" />                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua. </span><br>                             <hr class="micro-hr" />                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet, consectetur adipiscing elit.</span><br>                             <hr class="micro-hr" />                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet, consectetur adipiscing elit.</span><br>                             <hr class="micro-hr" />                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet, consectetur adipiscing elit.</span><br>                             <hr class="micro-hr" />                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua.</span><br>                             <hr class="micro-hr" />                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet, consectetur adipiscing elit.</span><br>                             <hr class="micro-hr" />                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet, consectetur adipiscing elit.</span><br>                             <hr class="micro-hr" />                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet, consectetur adipiscing elit.</span><br>                             <hr class="micro-hr" />                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua.</span><br>                      </td>                 </tr>                 <tr>                     <td class="fa fa-plus-circle">&nbsp;&nbsp;title 3</td>                     <td></td>                     <td></td>                     <td></td>                     <td></td>                 </tr>                 <tr>                     <td colspan="5">                         <!-- additional custom info here (for record 3) -->                         <div class="training-box">                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet</span><br>                             <hr class="micro-hr" />                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet</span><br>                             <hr class="micro-hr" />                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet</span><br>                             <hr class="micro-hr" />                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet</span><br>                             <hr class="micro-hr" />                             <span class="fa fa-arrow-circle-o-right">&nbsp;&nbsp;lorem ipsum dolor sit amet</span><br>                      </td>                 </tr>             </table>             <script>             $(function () {                 $('#example_table').jexpand();             });         </script>           </div>  </body> </html> 

followed javascript use plugin located in source files:

    <script>         $(function () {             $('#example_table').jexpand();         });     </script> 

as can see have made table html , have styled it... have used expand.js in order attempt making table expandable not seem working me. ideas?

the question why have set parameter inside html? have multiple tables in end in html?

the reason why not work because giving the: uncaught typeerror: $(...).jexpand not function.

if @ jsfiddle works: https://jsfiddle.net/k3s8okmo/

jscode:

$( document ).ready(function() {         var element = $('#example_table');         $(element).find("tr:odd").addclass("odd");         $(element).find("tr:not(.odd)").hide();         $(element).find("tr:first-child").show();         $(element).find("tr.odd").click(function () {             $(this).next("tr").toggle();         }); }); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -