我有一个文本区域,其中包含 anchor 标记形式的链接列表及其内部内容 例如
<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>
以上信息在文本区域内给出。我想在单击提交后检索特定类(如 tex1)的所有 anchor 标记的 href 部分。
例如我想要像
我如何使用 Jquery/javascript 实现此目的
最佳答案
试试这个
var text = $("textarea").val();
var res = $(text).map(function() {
return $(this).attr("href");
});
console.log(res);
关于javascript - 使用 jquery 从 textarea 获取 anchor 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27400800/