Показать сообщение отдельно
  #11 (permalink)  
Старый 11.03.2015, 16:37
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,075

table reverse localStorage
Sergei-b84,

<!DOCTYPE HTML>

<html>

<head>
  <title>Untitled</title>
  <meta charset="utf-8">
<style type="text/css">
    table {
      display: none;
    }
    #table_up{
      background: #339900
    }
    #table_down{
      background: #FF6666
    }

</style>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  <script>
     $(function(){
    var table = $('#table_up, #table_down'), f = localStorage.getItem('f')||'';
    function show()
    {
    $(table[+!f]).insertAfter(table[+f])
    table.show();
    };
    $('button').click(function(e) {
    f  =  f ? '' : '1';
    show();
    localStorage.setItem('f', f);
});
    show() ;
});


  </script>
</head>

<body>
<table id="table_up" class="table">
   <caption>Basic Table UP</caption>
   <thead>
      <tr class="success">
         <th>Name</th>
         <th>City</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td>Tanmay</td>
         <td>Bangalore</td>
      </tr>
      <tr>
         <td>Sachin</td>
         <td>Mumbai</td>
      </tr>
   </tbody>
</table>




  <table id="table_down" class="table">
   <caption>Basic Table Down</caption>
   <thead>
      <tr>
         <th>Name</th>
         <th>City</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td>Tanmay</td>
         <td>Bangalore</td>
      </tr>
      <tr>
         <td>Sachin</td>
         <td>Mumbai</td>
      </tr>
   </tbody>
</table>
<button>table reverse</button>

</body>

</html>
Ответить с цитированием