I have a ul that contain 2 li each of them have a text and a span that contain text like this
<ul>
<li>Erbil<span>text-1</span></li>
<li>Sulymany<span>text-2</span></li>
</ul>
i want to remove Erbil and Sulymany from the code with jquery.... I'm used this in jQuery
$('li').each(function () {
$('li').html($('span'));
});
but the result like this..
text-1text-2text-1text-2
text-1text-2text-1text-2
how to output only a span without repeating?
Try to use .html() and its receiver function to accomplish your task,
$('ul li').html(function(){
return $(this).find('span');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With