Czy w js mozna cos takiego wykonac ?
zalozmy ze mamy taki kod >
i chcialbym aby po zaznaczeniu checkboxa do wiersza w ktorym znajduje sie ten checkbox zostala dodana jakas klasa. jest to mozliwe ?
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script> <script> $( document ).ready(function() { $(".checkboxField").click( function() { $(this).addClass("innaKLASA"); }); }); </script>
<table id="tabela" border="1" align="center"> <tr class=""> <td ><input type="checkbox" class="checkboxField" ></td> </tr> <tr class=""> <td ><input type="checkbox" class="checkboxField" ></td> </tr> <tr class=""> <td ><input type="checkbox" class="checkboxField" ></td> </tr> <tr class=""> <td ><input type="checkbox" class="checkboxField" ></td> </tr> </table> <script src="https://code.jquery.com/jquery-1.12.3.min.js"></script> <script> $(document).ready(function(){ $(".checkboxField").click(function(){ $('#tabela input[type="checkbox"]:checked').each(function(){ $(this).parents('tr').addClass("dodanaKlasa"); alert($(this).parents('tr').attr("class")); }); }); }); </script>
alert($this.parent().siblings().find('td .age').text());
alert($this.parent().siblings(".age").text());