KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Edit : As of jQuery 1.4, using $() will work as described below. I need to loop through an array and create a number of elements which I want to have in a single jQuery result object. for (var i = 0; i < 10; ++i) { $myJQueryObj = $myJQueryObj.add($("<span>blahblah</span>")); } The problem with this, however, is that you need a jQuery object to begin with, and you obviously want to start it empty. In the above example, how should I initialise $myJQueryObj ? The following examples do not work, as they all select the document object: $('') $() $(null) $(false) These do work... but... $('#nonExistantElement') // yuck $().slice(0,0) // surely there's a nicer way? Is there a better way?
Tags (comma-separated)
Save Edits
Cancel