Skip to content
Advertisement

JavaScript setAttribute on page after run script

I have a script in HTML:

JavaScript

afterload page and script run to give other elements in the console. the code HTML now is:

JavaScript

this code <div id="de6854"> and <iframe id=”4526d” is change ID dynamically.

Now I want to change setAttribute src="https://www.ask.com/wp-content/uploads/sites/3/2022/02/PowerOfDogPromo.jpeg?resize=768,432" in <iframe id="4526d" after change check box.

I try code above but not working.

Advertisement

Answer

Is this useful for you?

JavaScript

Also you can add defer in your script tag. Like this <script defer>

In this way your script code executed after the document has been parsed.

You can use querySelectorAll for get multiple nodes.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement