简体   繁体   中英

jquery to get href in anchor tag using div/span ID selector and anchor tag class

Hi I'm new to jquery I just wanted to seek some help on getting the href attr in anchor tag using div/span ID selector and anchor tag class

<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>

Thanks :)

try

$('#view-post-btn').find('a').attr('href');
$('#preview-action').find('a').attr('href');

try this.

$('#view-post-btn').find('a.button').attr('href');
$('#preview-action').find('a.preview').attr('href');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM