How could I have a button display innerHTM text once it's clicked

Advertisements How could I make a button to respond by displaying the content inside saved in local storage //store value once entered localStorage.setItem(‘store’, JSON.stringify(ids1.value); let local = localStorage.getItem(‘store’); let button = document.getElementsByClassName(‘button’); let newd = document.getElementsByClassName(‘newd’); let parog = document.createElement(‘p’); parog.innerHTML = local; parog.style.display = ‘none’; if(local !== null){ button.addEventListener(‘click’, () => { newd[0].appendChild(parog.style.display =… Read More How could I have a button display innerHTM text once it's clicked

Pickles Exercise – change the text by using DOM

Advertisements <!DOCTYPE html> <head> <title>Pickles</title> <!–LEAVE THESE LINES ALONE, PLEASE! THEY MAKE THE LIVE PREVIEW WORK!–> <script src="node_modules/babel-polyfill/dist/polyfill.js" type="text/javascript"> </script> <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script&gt; </head> <body> <!–PLEASE LEAVE THIS LINE ALONE! MAKE YOUR CHANGES USING JAVASCRIPT!!–> <h1>Pickles Are <span>Delicious</span></h1> </body> </html> Select the element that currently reads "Delicious". Change its text to read "Disgusting" USING JAVASCRIPT. //… Read More Pickles Exercise – change the text by using DOM

I was trying to solve this : Whenever i will enter the mouse cursor in a parent div,the background color of that div will change randomly

Advertisements First I thought I solved the problem as everytime i entered the cursor inside the div, the background color changed randomly. But the issue was as long as i was keeping the cursor inside the div and moving over child elements, background color kept changing randomly. How will I fix it? <div class=”card-border” id=”triangleColorChange”>… Read More I was trying to solve this : Whenever i will enter the mouse cursor in a parent div,the background color of that div will change randomly

JQuery can load function fine, but onclick not

Advertisements This works fine: <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script&gt; <script type="text/javascript"> if (new Date().getMonth()===0) { $(document).ready(function(){ $("#mywistpetal").load("https://ry3yr.github.io/OSTR/Diarykeepers_Homepage/extrafiles/site/effects/wisteria_petal_rain.html&quot;); }); } </script> <div class="formClass"> <div id="mywistpetal"> </div> This fails however: <script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js”></script&gt; <button onclick=”mywFunction()”>Petals!</button> <script> function mywFunction() { $(“#mywistpetal”).load(“https://ry3yr.github.io/OSTR/Diarykeepers_Homepage/extrafiles/site/effects/snowflake.html&#8221;); } </script> <div class=”formClass”> <div id=”mywistpetal”> </div> </div> Why ? Is it different ? (I removed the onload as this is… Read More JQuery can load function fine, but onclick not

JQuery can load function fine, but onclick not

Advertisements This works fine: <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script&gt; <script type="text/javascript"> if (new Date().getMonth()===0) { $(document).ready(function(){ $("#mywistpetal").load("https://ry3yr.github.io/OSTR/Diarykeepers_Homepage/extrafiles/site/effects/wisteria_petal_rain.html&quot;); }); } </script> <div class="formClass"> <div id="mywistpetal"> </div> This fails however: <script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js”></script&gt; <button onclick=”mywFunction()”>Petals!</button> <script> function mywFunction() { $(“#mywistpetal”).load(“https://ry3yr.github.io/OSTR/Diarykeepers_Homepage/extrafiles/site/effects/snowflake.html&#8221;); } </script> <div class=”formClass”> <div id=”mywistpetal”> </div> </div> Why ? Is it different ? (I removed the onload as this is… Read More JQuery can load function fine, but onclick not

pick up a value from the button

Advertisements help me get the value from the button, I can not my code: <a href=”” onclick=”funk(this)” value=”123″ class=”price-button”><i class=”fas fa-shopping-cart”></i> press</a> <script> funk = (a) => { console.log(a.value) } </script> >Solution : Set a value in HTML and retrieve it on click with getAttribute <a href="" value="123" class="price-button" onclick="funk(this)"><i class="fas fa-shopping-cart"></i> press</a> const funk… Read More pick up a value from the button

Copy to clipboard with styles and show the text with styles when pasted

Advertisements i have a project that needs to copy strikethrough text here is the example site https://convertcase.net/strikethrough-text-generator/ i want to strikethrough the text and copy it with the styles and when i paste it somewhere it should show the same strikethrough text with styles. The website above applies styles even in google chrome search bar.… Read More Copy to clipboard with styles and show the text with styles when pasted

Why is this javascript function executing more times per second than it's supposed to

Advertisements I am working on a sort of clicker game where the user is able to buy upgrades. One such upgrade involves the user earning a certain amount of in-game currency per second, in this case 0.1. Unfortunately if the user decides to buy more than one of this upgrade it appears to rise exponentially.… Read More Why is this javascript function executing more times per second than it's supposed to

How can I change back the original value after modifying the text content in DOM with JavaScript

Advertisements Here’s the original value, <p class="welcome">Log in</p> Then I change it to "Welcome back, username" in DOM: const labelWelcome = document.querySelector(‘.welcome’) labelWelcome.textContent = `Welcome back, ${username}` But how can I change it back to "Log in"? This seems to have completely changed the original value, and I can only change it back by modifying… Read More How can I change back the original value after modifying the text content in DOM with JavaScript