Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get element, caused change event in javascript

i want to get know within onchange event handler, which control caused change (or blur) event. i tried to use jQuery $(":focus") for that aim, but

$('.some_class').change(function (e) {
    console.log(e.target);
    console.log($(':focus').get(0)); // always `undefined`.
    /* ......... other code......... */
});
like image 643
DotNetter Avatar asked Mar 11 '12 14:03

DotNetter


1 Answers

$('.some_class').change(function (e) {
console.log(e.target);
console.log($(':focus').); // just remove the .get(0)

}); remove the .get(0),you can get the element which is on focus

like image 137
Madao Avatar answered Sep 23 '22 13:09

Madao