Loosing the href value while .clone() & while doing .empty() help needed #javascript #jQuery
HTML:
<ul class="SegmentCommandsMenu">
<li class="segmentCommandReserve" style="display: list-item;">
<a href="javascript:openReservationPopup(4299,0,720)">
<img src="/QFlow/Images/Calendar/reserve.png" border="0" alt="Reserve">Reserve</a>
</li>
</ul>
Jquery:
var el = $('li.segmentCommandReserve').clone(); -
this returns the value but the href is ""
but then i tried to do set the value of href by doing the below:
el.find('a').attr('href',$('li.segmentCommandReserve').find('a').attr('href'));
but when i do the below the value of the href
if 'el
' is set back to ""
$('ul.SegmentCommandsMenu').html(''); or
$('ul.SegmentCommandsMenu').empty();
then i do this to get the element appended to the
$('ul.SegmentCommandsMenu').append(el);
Please help me to get this right . am i doing it wrong?