Cloud Stack Ninja

So I have a function which returns a string. I want that string to show up in a div, after a button is pressed in a different div.

<div >
   <button id="something"> something </button>
</div>
<div id="results">
   want result to show up here
</div>
const something = document.querySelector('#something');
something.addEventListener('click', someFunction);

someFunction(a, b){
......
// returns a string and takes two parameters, one parameter from the user 
}

const results = document.querySelector('#results');
// how to add return value of someFunction as text in the #results div?



Read more here: https://stackoverflow.com/questions/64401546/how-to-add-the-return-value-of-a-function-to-the-dom-as-text-that-displays-in-a

Content Attribution

This content was originally published by LiqSnk at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: