Replace text (with paragraphs) with a button


I’m trying to do something like this, except when I press the button I want that every paragraph have a different text. For example, in “This is a paragraph” display “Hello world” and in “This is another paragraph” display “Bye world”. Is that possible? I want to do this so bad :confused: Thank you for the help!

< script src=“”>< /script> < script> $(document).ready(function(){ $(“button”).click(function(){ $(“p”).text(“Hello world!”); }); }); < /script> < /head> < body>

< button>Set text content for all p elements< /button>

< p>This is a paragraph.< /p> < p>This is another paragraph.< /p>


You may try something like below,

    function changePara () {
     var getDiv = document.getElementById('paraGraph');
     getDiv.innerHTML = 'Bye World';

<input type='button' onclick='changePara ()' value='Change!'/>
<div id='paraGraph'>
 Hello World

Try above code here