Why does this code:
var jQueryString="div.data > div.item > div.quantity,div.article,div.price > :input";
$(jQueryString).live("click", function(event) { alert(this); });
output [object HTMLDivElement] instead of [object HTMLInputElement]?
I know this is a similar question to selector-find-live-returning-the-parent-from-a-multiple-selector, but I want a better solution (to get the HTML element I want modifying only the jQueryString).
updating
this was a code sample for didactic understanding, i can’t accept a solution like “define a jquery search string by each INPUT”, cuz in the real code there are a lof of INPUTS.
the answer of @Sotiris is too close to be perfect.
updating
the perfect solution is :: jQuery, Real :not operator equivalent
= thanks to all 😛 =
because in your selector you don’t select three inputs but two divs and one input.
div.data > div.item > div.quantityselect adivdiv.articleselect thediv.articlethe following select the input
In the following demo you can see that all of them alert
[object HTMLInputElement]using"div.data > div.item > div.quantity > :input,div.article > :input,div.price > :input"Demo: http://jsfiddle.net/FDNMD/7/