您好我是jquery的新手我只想寻求一些帮助,使用div / span ID选择器和锚标记类来获取锚标记中的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>
谢谢:)
答案 0 :(得分:5)
尝试
$('#view-post-btn').find('a').attr('href');
$('#preview-action').find('a').attr('href');
答案 1 :(得分:3)
试试这个。
$('#view-post-btn').find('a.button').attr('href');
$('#preview-action').find('a.preview').attr('href');