Graham Churchley schrieb: > > I want to hide the all table rows that have a specific value for the > custom 'grp' attibute. > This code works: > > $('table.grouped tr.group').click(function() { > > var attrName = $(this).attr("grp"); > > eval("$(this).siblings('[EMAIL PROTECTED]" + attrName + "]').toggle()"); > > return false; > > }) > > Basically, I get the 'grp' property value of the row that is clicked. > Then I toggle all siblings that have the same value for the grp attribute. > > Question: Is there a way to do this without using the eval method?
Yes, just remove eval and concatenate the selector string from the parts :-) $(this).siblings('[EMAIL PROTECTED]"' + attrName + '"]').toggle(); You don't really need the extra variable (at least in the example you gave): $('table.grouped tr.group').click(function() { $(this).siblings('[EMAIL PROTECTED]"' + $(this).attr('grp') + '"]').toggle(); }); In addition you don't need the "return false" because a table row does not have a default action to prevent. -- Klaus _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/