Is there any method that automatically push a newly created element(in html) in an array?

I’m creating a whatsapp chrome extension that sent me a notification whenever a specific keyword message is send in the group. So if someone sends a message then a new p tag is created with it’s innertext(whatever the message is). I want that p tag-innertext to be pushed in a msg_array, how to do that ?

That sounds like a job for JavaScript.

can u help me in some way ?

if someone sends a message then a new p tag

Make it so, when someone sends a message an object is created.

That object can be pushed into an array, and if object is created successfully the message is created, as well

this is the point where i m stuck , how to alert browser that a new object with “blah blah” class has been created ?

Create a variable with an empty array const messages = []

When function createPara runs instead of creating paragraph it push message to the messages array.

After message had been pushed, you would created paragraph from the messages array

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.