How do I get the value of checkbox?

Issue HTML : <input type="checkbox" aria-checked="false" class="cloud-private" value="" data-spm-anchor-id="a800.io"> My java script : ( i want to click this checkbox if it is not checked ,but this does not work ) var z = document.getElementsByClassName(‘cloud-private’); if (z[0].aria-checked==’false’){ z[0].click(); } Solution

Continue reading

javascript element.remove() not remove dom

Issue element.remove() seem to weird. <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”UTF-8″ /> <meta http-equiv=”X-UA-Compatible” content=”IE=edge” /> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″ /> <title>Document</title> </head> <body> <div id=”root”></div> </body> <script> class View { constructor() { this.parent = document.querySelector(‘#root’) } template() {

Continue reading

change footer size by id

Issue I am trying to run a function that changes the margin-top size according to what is being displayed. However, it doesn’t seem to be working? <body onload="changeFooter()"> <script> const heading = document.getElementById(‘verify’); const footer = document.getElementById(‘footer’) function changeFooter ()

Continue reading

Prevent global CSS being applied a component in Angular 5

Issue In .angular-cli.json, I got some global styles: “styles”: [ “../node_modules/bootstrap/dist/css/bootstrap.css”, “../node_modules/font-awesome/css/font-awesome.css”, “../node_modules/ng2-toastr/bundles/ng2-toastr.min.css”, “styles.scss” ], But I don’t want any of them being applied to a specific component – is it achievable? EDIT 1: Unfortunately, overriding the CSS style in

Continue reading

How to input without change focus

Issue Building an editor like below– I need the user to be able to select some text but then use the input to do something without losing the selection. function doReplace(){ const s = document.getSelection() if(s?.anchorNode.parentElement.id != “out”)return; console.log(‘replace’) out.innerText

Continue reading

Add new tag to the middle of element

Issue I am trying to surround specific words in textContent with HTML tags, this could hypothetically be done by doing element.textContent = element.textContent.replaceAll("word", "<h1>word<h1>"); but that isn’t parsed, and element.innerHTML= element.innerHTML.replaceAll("word", "<h1>word<h1>"); doesn’t work because there is a risk that

Continue reading

How can I run a function with an unavailable DOM object?

Issue I want to run a function to remove a button’s parent element. parent element after getting it with let rem_display_btn1 = document.getElementById(‘rem_display_btn1’); like this let rem_display_btn1 = document.getElementById(‘rem_display_btn1’); rem_display_btn1.addEventListener(‘click’, () => { let parentEl = rem_display_btn1.parentElement.parentElement; parentEl.remove(); }); The

Continue reading

Add new tag to the middle of element

Issue I am trying to surround specific words in textContent with HTML tags, this could hypothetically be done by doing element.textContent = element.textContent.replaceAll("word", "<h1>word<h1>"); but that isn’t parsed, and element.innerHTML= element.innerHTML.replaceAll("word", "<h1>word<h1>"); doesn’t work because there is a risk that

Continue reading

"AND" operator in CSS selectors

Issue I’m pretty familiar with xpath but not so much using css selectors in order to find a certain element. I know this xpath //input[contains(@value, "15.02.2022") would result into this css-selector input[value*="15.02.2022"]. But how would you translate this xpath //input[contains(@value,

Continue reading

Get selected option text with JavaScript

Issue I have a dropdown list like this: <select id=”box1″> <option value=”98″>dog</option> <option value=”7122″>cat</option> <option value=”142″>bird</option> </select> How can I get the actual option text rather than the value using JavaScript? I can get the value with something like: <select

Continue reading

Get selected option text with JavaScript

Issue I have a dropdown list like this: <select id=”box1″> <option value=”98″>dog</option> <option value=”7122″>cat</option> <option value=”142″>bird</option> </select> How can I get the actual option text rather than the value using JavaScript? I can get the value with something like: <select

Continue reading