I create jquery custom function.
I want fire event on selector sibling or child like this:
$.fn.CustomFunction = function() {
$(this).siblings("div").click(function(){
alert();
});
// OR
$(this + " > div").click(function(){
alert();
});
};
But it not work.
How i do this work?
You could try this:
$.fn.CustomFunction = function() {
$(this).on('click', 'div', function(){
alert();
});
);
It binds a click event on the selector div inside this.
More info: http://api.jquery.com/on/
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