1

Hi,

I have a javascript functions that can only run if certain element is present in the DOM. This element wont be there unless the user clicks a couple buttons. I want to do it so the elements appear anyway.

The ID of the element the user has to click is

topcmm-123flashchat-main-toolbar-message-type-option

if they click it, the element with the ID below will appear

topcmm-123flashchat-menu-style-topcmm-4

finally, if they click it, the element below will appear

topcmm-123flashchat-toolbar-style-send-sound-btn

is there any way to do this? How is it called?

Thank you.

1 Answer 1

1

You can get the element and trigger a click event in it. See the code below.

var l = document.getElementById('topcmm-123flashchat-main-toolbar-message-type-option');
//click on the first element
l.click();
//click on the second element
document.getElementById('topcmm-123flashchat-menu-style-topcmm-4').click();
Sign up to request clarification or add additional context in comments.

2 Comments

thanks but seems like the page freezes because the elements appear on screen quite a the same time. Is there any way to make them appear only within the document without showing them on screen?
On click handler, when you append your new element, you can set the style display: none; then, the element appended will be hidden.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.