开发者

Retrieving the text of a specified link tag not working

开发者 https://www.devze.com 2023-01-12 10:13 出处:网络
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,

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

精彩评论

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