Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.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 使用jquery从textarea获取锚定标记_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 使用jquery从textarea获取锚定标记

Javascript 使用jquery从textarea获取锚定标记,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我有一个textarea,其中包含锚定标签形式的链接列表及其内部内容 例如 <a href="http://example1.com/azaz" class="tex1"> Example 1</a> <a href="http://example1.com/aza" class="tex1"> Example 2</a> <a href="http://example1.com/za" class="tex2"> Example 3&

我有一个textarea,其中包含锚定标签形式的链接列表及其内部内容 例如

<a href="http://example1.com/azaz" class="tex1"> Example 1</a>
<a href="http://example1.com/aza" class="tex1"> Example 2</a>
<a href="http://example1.com/za" class="tex2"> Example 3</a>
<a href="http://example1.com/az" class="tex2"> Example 4</a>

以上信息在文本区域内给出。我想在单击submit之后检索特定类(如tex1)的所有锚定标记的href部分。 例如,我希望输出像


如何使用Jquery/javascript实现这一点

var text = $("textarea").val();

var res = $(text).map(function() { 

       return $(this).attr("href");
});

console.log(res);

ID应该是唯一的。因为您只是在筛选,所以更喜欢$.grep。有关$.Map和$.Grep之间的差异,请参阅