[英]How to get the text from anchor tag using Jquery
以下是我的錨標簽........
<display:setProperty name="paging.banner.full" value='<p><span id="hix-pagination"><span> <a id="id1" class="prev" href="{1}">◄◄</a>
我嘗試了以下使用jquery但沒有得到任何積極的結果.....
alert($('#id1').text());
alert($('#id1').html());
alert($('#id1').val());
你有正確的選擇器,如果你成功包含了jQuery,那么你可能需要document.ready也檢查你是否從DOM中獲取了html
$(function(){
alert($('#id1').html());
});
請參考此鏈接:
HREF:
$(function(){
$('div.res a').click(function(){
alert($(this).attr('href'));
});
});
文本:
$(function(){
$('div.res a').click(function(){
alert($(this).text());
});
});
$(document).ready(function()
{
$("#id1").click(function() {
alert($(this).text());
return false;
});
}
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.