Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.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
Jquery 将链接获取到数组中_Jquery_Html_Css - Fatal编程技术网

Jquery 将链接获取到数组中

Jquery 将链接获取到数组中,jquery,html,css,Jquery,Html,Css,我一直在尝试将某个div中的所有链接拉到一个数组中,并在页面的其他位置使用它们。这是用于MyBB软件的: <div class="pm_alert" id="pm_notice"> <div class="float_right"><a href="private.php?action=dismiss_notice&amp;my_post_key=d668d58abafb0f4ec8ab4c902e4eb460" title="Dismiss thi

我一直在尝试将某个div中的所有链接拉到一个数组中,并在页面的其他位置使用它们。这是用于MyBB软件的:

<div class="pm_alert" id="pm_notice">
    <div class="float_right"><a href="private.php?action=dismiss_notice&amp;my_post_key=d668d58abafb0f4ec8ab4c902e4eb460" title="Dismiss this notice" onclick="return MyBB.dismissPMNotice()"><img src="images/aesthetic/dismiss_notice.gif" alt="Dismiss this notice" title="[x]" /></a></div>
    <div><strong>You have one unread private message</strong> from <a href="http://localhost/mybb/member.php?action=profile&amp;uid=2">test account</a> titled <a href="private.php?action=read&amp;pmid=13" style="font-weight: bold;">take this</a></div>
</div>

也许错误就在于这样

.pm_link > a
应该是

.pm_alert a
试试

alert($('.pm_link > a').length)

是的,我只是打错了,谢谢你的帮助。这是最终起作用的代码:var link_split=$('.pm_alert a').map(function(){return This;}).toArray();警报(链接分割['0']);为什么不使用
var link_split=$('.pm_alert a').get()?您需要获得什么类型的数组?DOM元素数组、jQuery对象数组或内部文本数组?我需要整个元素。我刚刚意识到我的代码并没有像我想要的那样返回全部内容(而不仅仅是href)。有什么想法吗x
alert($('.pm_link > a').length)