If I had div's without id's or anything, but with the information that it is the last thing before the tag, is there a way I can use javascript to delete it? Example:
<body>
<div>don't delete</div>
<div>don't delete</div>
<div>don't delete</div>
<div>delete this div</div>
</body>
Thanks (I'm sorry if my question sucks, please tell me how I can improve it)
I also would not like to use jQuery
You can also use a plain CSS selector to get the last div immediately, instead of retrieving a collection.
document.querySelector('body > div:last-of-type').remove();
<body>
<div>don't delete</div>
<div>don't delete</div>
<div>don't delete</div>
<div>delete this div</div>
</body>