admin管理员组文章数量:1357633
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;
});
}
);
本文标签:
版权声明:本文标题:javascript - How to get the text from anchor tag using Jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743960299a2568900.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论