So I'm attempting to populate a select tag like so, using jquery, the range I'm choosing is actually pulled from a database but this simplifies things for you:
var select_tag = $("select");
for(var i = 0; i < 10000; i++)
{
$("<option value='" + i + "'>" + i + "</option>").appendTo(select_tag);
}
When I do this, the code take quite awhile to run and populate the select tag. So much so that a user might start to think that their browser closed and start clicking everywhere. Is there anyways I can speed the process up/optimize it so that it doesn't take this long?
Please note that the select tag itself is added to the page based on a click event, and is not loaded with the webpage right away. In this example a user is on one page, then the user clicks the 'Next' button, this triggers various functions one of which adds and populates the select element to the DOM. I just need a way to speed-up or optimize the process.