Showing posts with label jQuery. Show all posts
Showing posts with label jQuery. Show all posts

12/25/2014

Window orientation detection

Ref

I think the following codes would be useful when I want to make iDangerous swiper responsive to toggle mode between vertical and horizontal.

CSS3 :
@media screen and (orientation:landscape)
{
   body
   {
      background: red;
   }
}

11/24/2014

html table with fixed header

# Operation principles: 
ref: http://stackoverflow.com/questions/11499973/how-to-fixed-table-header-no-jquery


# Plug-in: 
ref: https://github.com/jmosbech/StickyTableHeaders 


 # Plug-in 2: with throttle.js for smoother scroll 
to-do: beautify scroller 
ref: http://tympanus.net/Tutorials/StickyTableHeaders/index3.html 


 # Plug-in doesn't work for me 
ref: http://www.fixedheadertable.com/

jQuery Table Manipulations

  • Add  to table
Ans. 1: prepend
Ref: http://stackoverflow.com/questions/23291138/add-thead-and-insert-first-tr-from-tbody-for-parent-table-only
$("document").ready( function() {
    $('table').each(function(){
    $(this).prepend('')
    $(this).find('thead').append($(this).find("tr:eq(0)"));
})});

Ans. 2: append & appendTo
Ref: http://stackoverflow.com/questions/12781886/jquery-add-thead-and-add-tbody
var myTable = jQuery("#myTable");
var thead = myTable.find("thead");
var thRows =  myTable.find("tr:has(th)");

if (thead.length===0){  //if there is no thead element, add one.
    thead = jQuery("").appendTo(myTable);    
}

var copy = thRows.clone(true).appendTo("thead");
thRows.remove();