title: move up/down and changing order javascript
body: <p>So i have a table with rows and two buttons attached to a column.when I click the up button the row is going up otherwise down. The problem is that i want to actualize the order for that columns. For example if my row it's going up then the column order should have the order of the row that it changed.How can I do this? My function in javascript:</p>
  
  <pre><code> $(document).ready(function () {
   $(".up, .down").click(function () {
  
       var $element = this;
       var row = $($element).parents("tr:first");
  
       if($(this).is('.up')){
           row.insertBefore(row.prev());
  
       }
       else{
            row.insertAfter(row.next());
       }
  
  });
  });
  
  
  
  
  &lt;tr&gt;
              &lt;td&gt;&lt;?php echo $row['id']; ?&gt;&lt;/td&gt;  
              &lt;td&gt;&lt;?php echo $row['title'];?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row['body'];?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $row['ord'];?&gt; &lt;button class='up'&gt;Up &lt;/button&gt; &lt;button class='down'&gt;Down &lt;/button&gt;&lt;/td&gt;
   &lt;/tr&gt;
  </code></pre>
  
  <p>Any suggestions?</p>