I am trying to change text using javascript, but I can't target this element no matter what...
<div class="elementor-element elementor-element-2d85236 elementor-widget elementor-widget-text-editor" data-id="2d85236" data-element_type="widget" id="is_connected" data-settings="{"ekit_we_effect_on":"none"}" data-widget_type="text-editor.default">
<div class="elementor-widget-container">
<div class="elementor-text-editor elementor-clearfix"><p style="text-align: center;"><span style="color: #ff0000;">Not Connected</span></p></div>
</div>
</div>
I want to change this "Not Connected" to "Connected" I tried with this, but it doesn't work:
var AddressText = $("#connect").html(address.substr(0, 13) "...")
var elems = document.getElementsByClassName(elementor-element elementor-element-2d85236 elementor-widget elementor-widget-text-editor)[0].innerText;
elems = "Connected"
CodePudding user response:
Wrap the selector inside '
document.getElementsByClassName('elementor-element elementor-element-2d85236 elementor-widget elementor-widget-text-editor')[0].innerText = 'connected'
CodePudding user response:
Here is the code you can try :
var elems = "Connected"
var AddressText = document.getElementsByClassName('elementor-element elementor-element-2d85236 elementor-widget elementor-widget-text-editor')[0].innerText = elems
CodePudding user response:
let spanTag = document.querySelector('.elementor-clearfix p').childNodes[1];
spanTag.innerHTML = 'Connetcted';
<div class="elementor-element elementor-element-2d85236 elementor-widget elementor-widget-text-editor" data-id="2d85236" data-element_type="widget" id="is_connected" data-settings="{"ekit_we_effect_on":"none"}" data-widget_type="text-editor.default">
<div class="elementor-widget-container">
<div class="elementor-text-editor elementor-clearfix">
<p style="text-align: center;">
<span style="color: #ff0000;">Not Connected</span>
</p>
</div>
</div>
</div>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
let spanTag = document.querySelector('.elementor-text-editor elementor-clearfix')[1];
spanTag.innerHTML = 'connected';
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
CodePudding user response:
You can also use textContent
to update the text
document.getElementsByClassName('elementor-element elementor-element-2d85236 elementor-widget elementor-widget-text-editor')[0].textContent = "Connected"