Why doesnt the following apply the css rules to both elements?
var prevElem = $('<a href="#" class="'+ settings.prev +'" />').text('Prev');
var nextElem = $('<a href="#" class="'+ settings.next +'" />').text('Next');
container.append(prevElem, nextElem);
$(prevElem, nextElem).css('top', container.height()/2);
Its only applied to prevElem.
Please note that the dynamic elements have been added to the DOM (with their classes) so they are there.
To do what you need, you must call
add()method.Reason you can’t join arrays by providing them as parameters to
jQuery, is that there is simply no such API. And there shouldn’t be because it would make it impossible to implement jQuery( selector [, context] ) which searches for elements within context.Check out $.add() for what you attempted to do.