Question

the image represents the html code:

fullimage: http://i.stack.imgur.com/izqd6.png and this is my jquery code:

$(".transaContentEdit").click(function(e) { 
   alert($(this).closest(".transe_row").find(".edit_transa").attr("class"));
   $(this).closest(".transe_row").find(".edit_transa").show();

});

the alert returns me undefined; The main idea is when i click on .transaContentEdit, i want to "show" the .edit_transa class. What is wrong with my code ?

Était-ce utile?

La solution

.transaContentEdit is at the same level with .edit_transa so you can't use .find() because .find() is use just to find childs from an element. You can try something like this:

$(".transaContentEdit").click(function(e) {
     alert($(this).closest(".transe_row").parent().find(".edit_transa").attr("class"));
     $(this).closest(".transe_row").parent().find(".edit_transa").show();
});

Autres conseils

$(".transaContentEdit").click(function(e) { 
   $(this).parents(".transe_row").parent().find(".edit_transa").show();
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top