jquery - get the text inside an anchor after clicking on the image -
i have several links similar following html, different text :-
<a class="rplink " href="#"> <span class="rpout"> <span class="rpexpandhandle"></span> <img class="rpimage" src="images/favourite.png"> <span class="rptext">baskets product </span> </span> </a>
i trying text (inside rptext) when user clicks on favourite image.
i have following jquery until :-
$('.rpitem').on("click", "img", function (e) { var text = $(this).find(".rplink").text(); e.preventdefault(); var args = { reportname: e }; alert($(this).attr('href')); $.ajax({ type: "post", url: "default.aspx/addtofavourites", data: json.stringify(args), contenttype: "application/json;charset=utf-8;", success: function () { }, error: function () { alert("fail"); } }); });
however cannot manage text.
if click event favourite img u can use siblings()
try this
$('.rpitem').on("click", "img", function (e) { $(this).siblings('span.rptext').text(); ....
Comments
Post a Comment