开发者

Jquery element creation on the fly

开发者 https://www.devze.com 2023-03-29 04:27 出处:网络
I am processing a JSON file and want to display the contents in a <div> i dont know the number of records of the json file so i want to create teh appropriate divs on the fly. how should i go ab

I am processing a JSON file and want to display the contents in a <div> i dont know the number of records of the json file so i want to create teh appropriate divs on the fly. how should i go about it?

the structure i am looking at is: <div class=1> <div class=2> 开发者_Python百科 <div class=3> </div></div></div>


var div = $('<div/>') will create an empty div, in which you can insert your data, and ultimately insert it into the DOM


Use $.each to loop through your JSON data as seen in this example from the docs

0

精彩评论

暂无评论...
验证码 换一张
取 消