How to target div at the end of the row?

前端 未结 3 388
萌比男神i
萌比男神i 2021-01-06 10:18

I am trying to insert a box strip in between rows of divs, how can I target the end of each row\'s div?

Here\'s a JSFiddle of the divs: http://jsfiddle.net/5Sn94

3条回答
  •  失恋的感觉
    2021-01-06 11:08

    You can use document.getElementsByTagName but it will only work if you don't have any other divs on the page http://jsfiddle.net/5Sn94/2/

    var divs = document.getElementsByTagName('div');
    divs[divs.length-1].style.border = '1px solid red';
    

提交回复
热议问题