So you want to know on what value you’ve clicked on, but the binding remains on the row?
Perfectly possible:
$(document).ready(function(){
$(".x").click(function(event){
console.log(event.target); //Log where you clicked
console.log($(event.target).text());
});
});
Why should this work?
In the event handler that we add to the clicking event when we click the elements with class x (every row), we pass a reference to the event itself.
In this reference we have access to a lot of information about the event, like in this case the target. The target is the Element where there is really clicked.
Because Javascript works with event bubbling, you do not need to set the handler on every element, but you can set it on a top level (even on ‘body’ would work), and with this (event.target) you can see where the user really clicked.
Because we now know the element that the user clicked, we can pass that reference to a jQuery object ($(event.target)) and utilise the text() function.
6
solved Access