![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 189 Pomógł: 1 Dołączył: 28.01.2008 Ostrzeżenie: (0%) ![]() ![]() |
Piszę skrypt w oparciu o jQuery i mam pytanie: Czy podany kod można uprościć:
Kod td = $(document.createElement('td')).appendTo(tr); select = $(document.createElement('select')).appendTo(td); optgr_opt = $(document.createElement('optgroup')).appendTo(select); Bo mam wrażenie jakbym nie postępował w myśl zasady DRY. Pozdrawiam |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Moderatorzy Postów: 15 467 Pomógł: 1451 Dołączył: 25.04.2005 Skąd: Szczebrzeszyn/Rzeszów ![]() |
Kod $('<td><select><optgroup /></select></td>').appendTo(tr); PS. popraw sygnaturkę |
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 189 Pomógł: 1 Dołączył: 28.01.2008 Ostrzeżenie: (0%) ![]() ![]() |
A tan kod:
Kod $(table + ' th').each(function(index) { $(table + ' tr').each(function() { $(table + ' tr td::eq(' + index + ')') }); Czy można go też uprościć? Ten post edytował S_Olewniczak 3.07.2009, 19:10:01 |
|
|
![]()
Post
#4
|
|
Grupa: Moderatorzy Postów: 15 467 Pomógł: 1451 Dołączył: 25.04.2005 Skąd: Szczebrzeszyn/Rzeszów ![]() |
Czepiłeś się tego podświetlania kolumn. (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)
Ja to bym zrobił tak: Kod var headers = $('#parent th'); headers.hover(function(){ $('#parent tr td:eq('+headers.index(this)+')').addClass('hover'); }, function(){ $('#parent tr td:eq('+headers.index(this)+')').removeClass('hover'); } ); Pisane z palucha, brak atestu Instytutu Matki i Dziecka. |
|
|
![]() ![]() |
![]() |
Aktualny czas: 23.08.2025 - 21:20 |