i need the result in a html paragraph
<p id="result">Here the Button Text</p>
This is the Html part
<button type="button" id="vteam">i need this text</button>
This is the JS part
$(document).on('click', '.vteam', function(event) {}
i need the result in a html paragraph
<p id="result">Here the Button Text</p>
This is the Html part
<button type="button" id="vteam">i need this text</button>
This is the JS part
$(document).on('click', '.vteam', function(event) {}
-
Example
$('#vteam').on('click', function(e) { $(this).text('text here')})
– Aks Jacoves Commented Sep 5, 2020 at 12:33
3 Answers
Reset to default 6event.target
refers to the clicked element, so you can get the text inside it like so: event.target.innerText
.
I think you can use the following:
function changeText() {
document.getElementById("vteam").innerHTML = "Hello";
}
and
<p id="vteam" onclick="changeText()">I need this text to change</p>
You can give your inner text as an id to element .and in event handler you can access your inner text by this way:
e.target.id