Answer the question
In order to leave comments, you need to log in
How to clear class and id?
Hello everyone again, the problem is)
The bottom line is that when loading, a code is executed that fills the ul class with li elements using php, there is a js script that also fills the ul class with li elements during its work, but adds its entries to the end of the entire list, the question is how to clear the list if Is this or that code being executed?
here is the 1 fill code
<?php //Вывод аудио
if (!empty($audio['response']['items'])) { ?>
<?php foreach ($audio['response']['items'] as $item) { ?>
<li><a href="<?= $item['url'] ?>"><b><?= $item['artist'] ?></b> - <?= $item['title'] ?> <span class="label"><?= $item['aid'] ?></span></a></li>
<?php } ?>
<?php } ?>
<script type="text/javascript">
VK.init({
apiId: 5135424
});
function recommendate(){
VK.Api.call('audio.getRecommendations', {count: '1000'}, function(r) {
if(r.response) {
$('#playlist').append('<li><a href="'+r.response[0].url+'"><b>'+r.response[0].artist+'</b> - '+r.response[0].title+'<span class="label">'+r.response[0].aid+'</span></a></li>')
}
});
};
</script>
<ul class="sm2-playlist-bd" id="playlist">
Answer the question
In order to leave comments, you need to log in
judging by the JS code, it pulls 1000 records and inserts only the first one? what is the question at all?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question