سؤال

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 ?

هل كانت مفيدة؟

المحلول

.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();
});

نصائح أخرى

$(".transaContentEdit").click(function(e) { 
   $(this).parents(".transe_row").parent().find(".edit_transa").show();
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top