嗨,我是 jquery 新手,我只是想寻求一些帮助,以使用 div/span ID 选择器和 anchor 标记类获取 anchor 标记中的 href attr
<span id="view-post-btn"><a href="https://blog.company.com/site1/archives/team/post-1" class="button button-small">View Member</a></span>
<div id="preview-action">
<a class="preview button" href="https://blog.company.com/site1/archives/team/post-1" target="wp-preview" id="post-preview">Preview Changes</a>
谢谢:)
最佳答案
尝试
$('#view-post-btn').find('a').attr('href');
$('#preview-action').find('a').attr('href');
关于javascript - jquery使用div/span ID选择器和 anchor 标记类获取 anchor 标记中的href,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22981243/