Je fonction JS qui parse par une table:JQuery: comment sélectionner table parent pour l'analyse syntaxique
// id contains a message id, activeRow is "this" from onClick on tr
function doSomething (id, activeRow) {
// AJAX calling using id as parameter
$("#searchResultTable > tbody > tr").each(function(index) {
$(this).removeClass("bold");
});
}
Cela fonctionne parfaitement bien (grâce à Ariel @other post), mais je pense qu'il devrait y avoir une autre possibilité, comme:
var table = $(activeRow).parent();
$("tbody > tr", table).each(function(index) {
// .. do something
});
// The above clearly doesn't work, but should document what I'm looking for.
Cela permettrait l'utilisation du même ID de table tandis que la fonction travaillerait sur chacun d'eux séparément.
Beaucoup, merci beaucoup!
Je sais que cette réponse a été plutôt tardive, mais j'ai trouvé cette réponse sur un certain nombre de recherches sur google, alors j'ai pensé que cela valait la peine de contribuer. –