开发者

Retrieving the text of a specified link tag not working

so I have a few links that have a class of 'button', and I am trying to get their tex开发者_如何学JAVAt values with the jQuery .text() function, but it is returning nothing at the moment,

code:

$(document).ready(function() {

 var tester = $('a.test').text();

 alert(tester);
});

HTML:

<a class='test'>TEST</a>

any idea why this might not be working?


This code works, just try....

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
    <a class="test">Test</a>

  <p></p>
<script>
   var string = $("a.test").text();
   alert(string);
</script>

</body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜