How to get the text from anchor tag using Jquery

mukund picture mukund · Mar 6, 2013 · Viewed 17.4k times · Source

The following is my anchor tag........

<display:setProperty name="paging.banner.full" value='<p><span id="hix-pagination"><span> <a id="id1" class="prev" href="{1}">&#9668;&#9668;</a>

And I tried the following using jquery but did not get any positive result.....

alert($('#id1').text());
      alert($('#id1').html());
      alert($('#id1').val());

Answer

Adil picture Adil · Mar 6, 2013

You have right selector, if you have jQuery included successfully then you may need document.ready also check if you get html out of DOM

Live Demo

$(function(){
   alert($('#id1').html());
});