Home > Enterprise >  How to chop of blooger api content?
How to chop of blooger api content?

Time:11-17

Hi I am using blogger api. I get response for a post like this

<h4 style="text-align: left;">              <span style="font-family: Poppins;"><b>Chapter-1  “THE END OR A START?”</b></span></h4><h4 style="text-align: center;"><span style="font-family: Poppins;"><b>&nbsp;</b></span></h4><h1 style="text-align: left;"><b><i><div  style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiApnHT6ldTH65AEU-Yi8eztBl4c0kD2KfLT8UP9qqf_k8oMcacZbdcDaUcuhDQXqhOQDVNPswymSmXiGH9qvKwD3JUiznA9b-X6-rXs0Z1awQACr7WGlmcFZJeIMmBSW_35Oa9h8UVbrkZhMqLTYoMAr0V9i_WyYHsWXva1sq0h0XOsS3e1i47om9byA/s1024/WhatsApp Image 2022-11-14 at 11.35.09 PM.webp" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" 

Its just a little bit of sample. I get a long content like this. Basically what I want to do is I want to display only some chunk of those response. How can I chop off. I tried using splice (0, 500) but it is not displaying anything. How can I solve it?

CodePudding user response:

You can remove the last element by using the removeChild() method. If you put that in a for loop you can choose how many elements you delete.

let div = document.getElementById('yourDiv')
let numberToDelete = 2;
for(i = 0; i < numberToDelete; i  ){
     div.removeChild(div.lastElementChild);
}

This code should remove the last two elements from a div.

  • Related