jquery - How to get the previous text value of a div by clicking a html item? -
in image below html code:
and js code:
$(".salveazatransasuma").click(function(){ var payment_name = $(this).siblings().previous(".transacontentedit").text(); alert(payment_name); });
so want text value transacontentedit
class, when click on salveazatransa
class. don't worry white spaces before , after text value ("servicii programare transa 1"). appearantly code doesn't work. gives me error in firebug "typeerror: $(...).siblings(...).previous not function". idea how hande ?
based on image, can use:
$(".salveazatransasuma").click(function(){ var payment_name = $(this).closest('.litransa').prev().find(".transacontentedit").text(); alert(payment_name); });
Comments
Post a Comment