There is a code that displays entries from VC:
<div id="answerPlaceHolder"></div> <script> var placeHolder = $('#answerPlaceHolder'); var url = 'https://api.vk.com/method/wall.get?owner_id=-78812318&count=20&filter=all&v=5.45'; var answer; $.ajax ({ url:url, type:'get', crossDomain:true, dataType:'jsonp', success:function(response) { answer = response; var counter = 1; answer.response.items.forEach(function(item) { // console.log('Пост № ' + counter); if ((item.text != 'undefined') && (item.text != '')) { placeHolder.append('<div class="blog-header">' + item.text + '</div>'); //console.log(item.text); } // console.log(item); if ((typeof(item.attachments) != = 'undefined') && (item.attachments[0].type == 'photo') && (typeof(item.attachments[0].photo.photo_604) != = 'undefined')) { placeHolder.append( '<img width="560px;" src="' + item.attachments[0].photo.photo_604 + '"> <div class="blog-share"><a href="http://gamer-by-life.com/share/?title=' + item.text + '&img=' + item.attachments[0].photo.photo_604 + '&time=' + item.date + '"><img src="share.png"></a></div>' ); // console.log(item.attachments[0].photo.photo_604); } counter++; console.log('******************************\n'); placeHolder.append('<br>'); }); }, error: function(error) { console.log('Ошибка'); console.log(error); } }); </script>
Posts are displayed in this format:
<div class="blog-header">Тут текст (когда он есть) </div><img width="560px;" src="картинка"><br>
How to do what would be displayed in this:
<div class="post"><div class="blog-header">Тут текст (когда он есть) </div><img width="560px;" src="картинка"><br></div>