Sorry for the title may seem confusing.
i have 2 element. with no relation like parent or child.
<div class开发者_运维技巧="alpha"></div>
<div class="beta"></div>
The class=alpha
have event, if we click it's, there is will be a fade in or fade out element (which is done by jQuery).
now i want to make simulation like. if we click class="beta"
it will be the same as we click class="beta"
.
more details is like if we click beta
the alpha
will show it's fadein fadeout effect :)
how we can make it?
many thanks
In jQuery, you can call the .click()
function directly or make use of .trigger()
and pass it "click"
. So either:
$(".beta").click();
Or
$(".beta").trigger("click");
Either one of these methods will call your click handler for .beta
If you meant to ask, if I click .alpha
, I want to simulate a click on .beta
, then this is what you want:
$("body").delegate(".alpha", "click", function() {
$(".beta").click();
});
now i want to make simulation like. if we click class="beta" it will be the same as we click class="beta".
Not 100% sure what you mean with that. My guess is what you want is...
$('.alpha').click(function() { $('.beta').click(); });
I think you mean "if we click class="beta" it will be the same as we click class="alpha"
If that's the case
$('div.beta').click(function(){
$('div.aplha').trigger('click');
});
精彩评论