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}">◄◄</a>
And I tried the following using jquery but did not get any positive result.....
alert($('#id1').text());
alert($('#id1').html());
alert($('#id1').val());
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}">◄◄</a>
And I tried the following using jquery but did not get any positive result.....
alert($('#id1').text());
alert($('#id1').html());
alert($('#id1').val());
Share
Improve this question
edited Mar 6, 2013 at 9:46
Yevgeniy
2,6941 gold badge20 silver badges27 bronze badges
asked Mar 6, 2013 at 9:44
mukundmukund
3275 gold badges10 silver badges22 bronze badges
3
- Are you sure you have latest jquery.js imported in your workspace ? – The Dark Knight Commented Mar 6, 2013 at 9:48
-
text() and html() should work - what do they output in your example? Chances are it's a mistake at a more basic level, such as not importing jQuery as @TheDarkKnight suggests. Could also be you forgot to wrap it in
$(function() { ... } )
to make sure the dom is loaded. – Armatus Commented Mar 6, 2013 at 9:50 - possible duplicate of link and link2 – jeev Commented Mar 6, 2013 at 9:54
3 Answers
Reset to default 4You 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());
});
Refer this link :
How to get anchor text/href on click using jQuery?
Get text from anchor tag
href:
$(function(){
$('div.res a').click(function(){
alert($(this).attr('href'));
});
});
Text:
$(function(){
$('div.res a').click(function(){
alert($(this).text());
});
});
$(document).ready(function()
{
$("#id1").click(function() {
alert($(this).text());
return false;
});
}
);