The comments are useful but don’t give you an exact answer. text
is not a function on a DOM element, but textContent
is a property of DOM elements which you can use:
function fn(event){
let obj = event.target;
let x = parseInt(obj.textContent);
console.log(x);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="parent" oncontextmenu = 'return false'>
<div class="title" oncontextmenu = 'fn(event)'>5</div>
</div>
3
solved text is not a function error using event.target