Change text in a javascript generated window with javascript

41 views Asked by At

I use an external consent tool on my webseite (inmobi choice). The tool is loaded with an async javascript and opens a window on my website to ask for consent.

Is it somehow possible to change text with javascript or jquery in this javascript generated consent tool window?

I am able to change texts in my local website for example with document.getElementsByClassName("myClass")[0].innerHTML = 'new text'; or $(".myClass").text('new text');

But that does not work in the javascript generated window of the consent tool.

The javascript window of the consent tool looks like this

<div class="qc-cmp2-container" id="qc-cmp2-container" data-nosnippet="">
  <div class="qc-cmp2-main" id="qc-cmp2-main" data-nosnippet="">
    <div id="qc-cmp2-ui" role="dialog" aria-label="qc-cmp2-ui">
      [...]
      <div class="qc-cmp2-consent-info">
       Text to be changed...
     <div>
    <div>
  <div>
<div>

With console.log(document.getElementsByClassName("qc-cmp2-consent-info")); I can see the text in the console, but was not sucessfull to change it.

HTML Collection []{
  0: div.qc-cmp2-consent-info
    1: {scrollfalse: f}
    ...
    innerHTML: "Text to be changed..."

For example $(".qc-cmp2-consent-info").text('new text'); shows no change

1

There are 1 answers

1
Paplepel93 On

Have you tried using $(".qc-cmp2-consent-info").val('new text'); ?