I am working on below jQuery code and target is to change content of any tag is clicked by the user.
I am fine with getting the id of clicked element but not able change its content.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("td").click(function(){
var elementID = $(this).attr('id');
alert(elementID); //I am OK by accessing the elementID
$("#elementID").text("X"); // How pass this elementId again in order to change content ?
});
});
</script>
$(this), just like you did in the first row of the function...