If I have something like this:
$(".jq_elements").children("input").click(function()
How do I add another selector to it, so that same event gets fired up when either one is clicked.
Basically something like this would be needed:
$(".jq_elements, .jq_another_div").children("input").click(function()
Is something like this possible?
edit: I did try this the way that I described above. Turns out my code was a bit crooked, but its fine now.
You can specify any number of selectors to combine into a single result. This multiple expression combinator is an efficient way to select disparate elements. The order of the DOM elements in the returned jQuery object may not be identical, as they will be in document order.
Can you chain selectors in jQuery? With jQuery, you can chain together actions/methods. Chaining allows us to run multiple jQuery methods (on the same element) within a single statement.
To select multiple elements of an html page using multiple elements selector, we pass the element names inside parenthesis, in double quotes, separated by commas. For example: $(“div, p, h2”) this will select all the div, p and h2 elements of a page.
So far we have covered only three standard jQuery Selectors. For a complete detail of all these jQuery selectors, you can go to through jQuery Selectors Reference.
$("selector, selector")
That very syntax works. Do you want to call .children("input")
on both?
Alternatively $.merge($("selector"), $("selector"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With