po dynamicznym dodaniu elementów tabeli, nowe <tr> nie podlegają regule podświetlania
czemu to nie działa i co zrobić żeby zaczęło:
<html> <head> <script type="text/javascript"> $(document).ready(function(){ $('#button').click(function(){ var id = $('#input1').val(); var val = $('#input2').val(); $('#tab').append(newTR); }); $('#tab tr').hover(function(){ $(this).css('background','red'); }, function(){ $(this).css('background',''); } ); }); </script> </head> <body> <form id='form1' name='form1'> <input id='input1' name='input1' value=''/> <input id='input2' name='input2' value=''/> </form> <table id='tab' name='tab' style='width: 400px;' > <tr> </tr> <tr> </tr> </table> <input id="button" type="button" value="Click Me" /> <body> </html>
ciekawe jest ze jesli dodaje nowe elementy do <selecta> to możemy z nich zczytywać wartości czyli uzyskujemy dostęp to nowo wygenerowanych elementów:
tak jak tu:
<script type="text/javascript"> $(document).ready(function(){ $('#button').click(function(){ var id = $('#input1').val(); var val = $('#input2').val(); $('#sel').append(newTR); }); $('#sel').change(function(){ var s = $('#sel').val(); alert(s); }); }); </script> </head> <body> <form id='form1' name='form1'> <input id='input1' name='input1' value=''/> <input id='input2' name='input2' value=''/> </form> <select id='sel' name='sel'> </select> <br> <input id="button" type="button" value="Click Me" />
z góry dzieki za odpowiedz