I have a list with p tags inside. I want to get the size of each text and then crop it. I have this:
<script>
var text;
for(var i=0;i<document.getElementsByTagName("p").length;i++){
console.log(document.getElementsByTagName("p")[i].length+ "");
if(text[i].length > 12) {
text[i] = text[i].substring(0,10)+"...";
}
}
</script>
The problem is that it gives me undefined. I also had another question. Where should I put this piece of code, inside the head or at the end of the body? Would it be better to do it with jQuery?