Home > Enterprise >  Is it possible to select a visible element on a page with javascript, if it is not in the page sourc
Is it possible to select a visible element on a page with javascript, if it is not in the page sourc

Time:01-19

I'm try to use javascript to select/auto submit a form that is visible on the page, but it is not in the HTML source of the page. I can see the submit button but there is no iframe or HTML for it in the source of the page. The form was generated with javascript. Is it possible to select this "element" (the submit button) if it isn't in the page source code?

CodePudding user response:

Yes. It's possible.

As soon as the button element is inserted into the DOM, you can select it.

CodePudding user response:

The source code will only show you the code it received from the server, everything that javascript does it happens after that and it's added to the DOM dynamically.

You can look at the developer tools on your browser (F12) and you would be able to inspect the javascript-created elements.

With that information you can select the form using its ID, class name or even the form itself. Not sure what framework you're using, of if it's plain vanilla Javascript. If you let me know which one I can provide some examples.

  •  Tags:  
  • Related