Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 检索指定链接标记的文本无效_Javascript_Jquery_Html - Fatal编程技术网

Javascript 检索指定链接标记的文本无效

Javascript 检索指定链接标记的文本无效,javascript,jquery,html,Javascript,Jquery,Html,所以我有几个链接有一个“button”类,我试图用jQuery.text()函数获取它们的文本值,但它目前没有返回任何内容 代码: HTML: 测试 你知道这可能不起作用的原因吗?这段代码行得通,试试看 <html> <head> <script src="http://code.jquery.com/jquery-latest.min.js"></script> </head> <body> <a clas

所以我有几个链接有一个“button”类,我试图用jQuery.text()函数获取它们的文本值,但它目前没有返回任何内容

代码:

HTML:

测试

你知道这可能不起作用的原因吗?

这段代码行得通,试试看

<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>

试验

var string=$(“a.test”).text(); 警报(字符串);
Nvm,似乎已经开始工作了,我的jQuery库没有被正确引用!没有错!反正是Thanx!
<a class='test'>TEST</a>
<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>