Here's is what I'm trying to get
<a href="default.aspx?propid=BARN" class="topbook"></a>
The above link should clone the sidelink that has display:block
<a href="default.aspx?propid=FARM" class="sidelink"></a>
<a href="default.aspx?propid=HANW"开发者_运维问答 class="sidelink"></a>
<a href="default.aspx?propid=BARN" class="sidelink" style="display:block"></a>
But I'm getting
<a href="default.aspx?propid=FARM" class="topbook"></a>
Because it is copying the first instance of sidelink href
Here's my code
$('.topbook').attr('href', $('.sidelink').attr('href'));
Hope this helps
Thanks
Jamie
You could conceivably use
$('.topbook').attr('href', $('.sidelink[style$="block"]').attr('href'));
but please don't.
Instead, give the .sidelink
element whose href
you're trying to copy a different class or something, don't use the style
attribute to differentiate it from the others.
精彩评论