by skilled · 3y ago · 0 comments
> I am a novice in the world of JavaScript and, as part of my learning journey, I've undertaken the task of attempting to manipulate the Document Object Model (DOM). Specifically, my aim is to add a new div element dynamically to my webpage, utilizing the common programming language called JavaScript.
> This snippet of code is my current attempt:
var newDiv = document.createElement("div");
newDiv.id = "newDiv";
newDiv.innerHTML = "This is a new div.";
document.body.appendChild(newDiv);
> The logic behind the above code snippet is as follows:> - I create a new div element by invoking document.createElement("div") and assign it to the variable newDiv.
> - I then assign an id to the newly created div by setting newDiv.id to "newDiv".
> - To add content to the div, I set newDiv.innerHTML to "This is a new div."
> - Lastly, I attempt to append the new div to the body of the document using document.body.appendChild(newDiv).
> Nevertheless, the code does not seem to produce the "div" I was hoping for. Additionally, there are no errors displayed on the console. I have attempted to diagnose the issue myself but have failed, and I have exhausted all other online resources
> Time is of the essence. Additionally, I would prefer this answer to be as concise and easy to understand as possible. Your guidance and assistance in this matter is very much appreciated.
> Thanks in advance,
> user4798145768
0 comments
Even better, we can further optimize the experience by simplifying all news websites, reddit, SO networks to just a few empty HTML pages with ads so the can be clicked by the AI. No need for content, agencies, editorial staff.
I mean, sure, Facebook, Microsoft and Google would probably say that's against the TOS of their ad services, but after all it's not like they cared about TOSes when they used the same websites to train their models.
It's a uBlock Origin fork that behaves as described.