css - jQuery addClass to parent and it's siblings -
i trying apply class element's parent , it's siblings. far have been successful applying 2 lines of jquery makes end result apply in 2 stages looking pretty ugly.
<style type="text/css"> td.rostered { opacity: 0.3; } </style> <table> <tr class="flight_search"> <td class="" style="width: 6%; text-align: left"><img id="525" class="roster" src="images/link_image.png" alt="link image"></td> <td class="" style="width: 7%">option 1</td> <td class="" style="width: 24%">london -<strong>paris</strong></td> <td class="" style="width: 25%">dep: <strong>0355</strong> arr: 0615 (02:20)</td> <td class="" style="width: 30%">boeing 767</td> <td class="" style="width: 8%"><a class="rego" href="#">abcde</a></td> </tr> </table>
when user clicks image (with id="525") ajax runs assign flight user's roster. returns id run jquery grey-out row of table, indicating rostered.
function set_rostered(id) { //this line adds class 'rostered' siblins of <td> $("#" + id).parent().siblings().addclass('rostered'); //this line removes id flight cannot rostered again , adds class parent <td> itself. $("#" + id).attr('id', '').parent().addclass('rostered'); }
is there way can combine these 2 lines of code make class apply elements (parent , it's siblings) @ same time?
try adding (with addback() function):
$("#" + id).parent().siblings().addback().addclass('rostered');
Comments
Post a Comment