jQuery issue

beginning to learn jQuery and finally got to my first hiccup while testing my skills. So I want to add some interactivity to my web page by allowing the user to put text on the web page. I try this by using an input, paragraph, and button elements. I attempted to make this function work so that when they click the button element that the text inside the input would replace the text inside the paragraph, but this does not work for some reason. Any help would be appreciated.

html

<p class="interactive"> sample text</p>
<input type="text" class="inputText">
<button class= "changeText">input text</button>

jQuery

let inputText = document.getElementsByClassName('inputText').textContent;

$('.changeText').click(function(){
$('.interactive').text(inputText);

})

solved it. this is what I did with my jQuery.

$('.changeText').click(function(){

const inputText = $(".inputText").val()

const interactive = $('.interactive').text(inputText);

})

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.