1 Temmuz 2010, PERŞEMBE
jQuery tablo sıralama
4 sütun ile çok basit bir HTML tablo var:
Facility Name, Phone #, City, Specialty
Bu Tesis kullanıcı adı ve Şehri tek sıralamak mümkün olmak istiyorum.
Nasıl bu kullanarak jQuery kodunu alabilir miyim?
CEVAP
1 Temmuz 2010, PERŞEMBE
Eğer çan ve ıslık sonra tüm önlemek istiyorsanız this simple sortElements
plugin öneririm. Kullanımı:
var table = $('table');
$('#facility_header, #city_header')
.wrapInner('<span title="sort this column"/>')
.each(function(){
var th = $(this),
thIndex = th.index(),
inverse = false;
th.click(function(){
table.find('td').filter(function(){
return $(this).index() === thIndex;
}).sortElements(function(a, b){
if( $.text([a]) == $.text([b]) )
return 0;
return $.text([a]) > $.text([b]) ?
inverse ? -1 : 1
: inverse ? 1 : -1;
}, function(){
// parentNode is the element we want to move
return this.parentNode;
});
inverse = !inverse;
});
});
And a demo.("Ekle" ve "tesis sütun başlıkları sıralamak için"). şehir
Bunu Paylaş:
Bir şekilde jquery DataTable sıralama ...
JQuery ile tablo oluşturmak - eklemek...
Nasıl bir tablo jQuery kullanarak orta...
JQuery tablo satır ve sütun sayısı...
JQuery ile bir tablo satırı kaldırmak ...