i creating some a-tags and store this in different variable. Now, i want add a hover event to this stored variable.
something like that
var btnPrev = $(document.createElement('a'));
btnPrev.css({
'display':'block',
...
});
btnPrev.text('<');
btnPrev.addClass('issueBtnPrev');
var btnNext = $(document.createElement('a'));
btnNext.css({
'display':'block',
...
});
btnNext.text('>');
btnNext.addClass('issueBtnNext');
now here is the hover event
(btnNext,btnPrev).hover(function() {
$(this).fadeTo(200,'0.3');
}, function() {
$(this).fadeTo(200,'.2');
});
but only the btnPrev have a hover effect is there a way to attach more than one vaiable to a hover effect.
i know i can use
$(‘.issueBtnNext, .issueBtnPrev’).hover
You can use the
addmethod to add another jQuery object (or an element, HTML fragment, etc.) to the current set:From the jQuery docs on
add:Your current attempt only works for
btnPrevbecause you are using the comma operator which evaluates both of its operands (which in your case does nothing) and returns the last, which in your case isbtnPrev.