I want to do some actions when class .smth is clicked
$('.smth').click(function() {
and when key is pressed:
$('.txt').bind('keypress', function(e) {
I want to do the same action, so how can I use them both with OR or something like that?
$('.log').click.or.$('.txt').bind('keypress', function(e) {
?
THank you.
Joint probability is a statistical measure that calculates the likelihood of two events occurring together and at the same point in time.
Is it possible for two events happen at the exact same time? No. Even at any one event itself there can be several (or in though-experimental principle even arbitrarily many) distinct participants (encountering and passing each other, momentarily).
If you have two meetings scheduled for the same time, you could use the word concurrent, but you're more likely to use the word simultaneous.
Synchronous describes two or more things happening at the same time, as in The fire resulted in the synchronous events of the fire alarm going off and the sprinkler system activating.
If this was the same collection of elements you could use:
$(".myclass").bind("click keypress", function(event) {
//...
});
But as it's different elements you'll have to follow Felix advice and write a function then attach it as the event handler.
Use a named function instead of an anonymous one.
function handler() {
//...
}
$('.txt').keypress(handler);
$('.smth').click(handler);
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