Convert string of numbers to different divs with classes. Either Jquery or Ajax -


so have string of numbers echo'ed database. string of numbers like:

var numbers = "12,156,4,198,759" 

i want string printed in different divs such as

<div class="div-12"></div> <div class="div-156"></div> <div class="div-4"></div> <div class="div-198"></div> <div class="div-759"></div> 

this string create massive number of divs, few thousand.

this either done ajax or pure client side jquery. however, ajax preferred.

i have no idea how go doing this. not quite ajax, not have go in detail.

please me out :)

assuming you've got data ajax call comma-separated list of number, can this:

http://jsfiddle.net/rra3u/1/

var numbers = "1,2,3,4,5,99";  var list = numbers.split(",");  $.each(list, function(index, value){     $("#container").append("<div>").class("div-" + value).text("div " + value)); }); 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -