I'm calling this php file from Ajax and writing the required javascript code in this php file.
<div class="add_people_invite">
<button class="btn btn-default add_connection" id="right_connection_request" onclick="SentRequestMouseUpRight(event,{{ $peopleMayKnow->id }})">
<span>My Text</span>
</button>
</div>
Javascript code :
<script>
function SentRequestMouseUpRight(event, user_id) {
if (event.which == 1) {
alert();
$("#right_connection_request span", this).text("My NEW Text");
}
}
</script>
alert in javascript is working but it is not changing the text to My NEW Text and if I remove this and then I run this code $("#right_connection_request span").text("My NEW Text"); It changes the text.
thishere anyway? You're using an ID and IDs as such must be unique.thisto refer to the clicked element, you'd need to use.call(this, …