In an example I am having this structure (small example):
<table id=example>
<tr class="blah test example"><td>Test1</td><td><a href="url">LINK</a>Test11</td></tr>
<tr class="blah test example"><td>Test2</td><td><a href="url">LINK</a>Test22</td></tr>
<tr class="blah test example"><td>Test3</td><td><a href="url">LINK</a>Test33</td></tr>
</table>
In jQuery I would create it dynamically like:
var test = "<table id=" + someIDVar + ">"
+ "<tr class=" + classOneVar
+ classTwoVar + classThreeVar + ">"....
and etc etc... (lots of other stuff to write). After I would just append it:
$(".somePlaceInHtml").append(test);
So is there any other way to write such a structure dynamically with jQuery? This is a problem for me because I am having a big structure, not as small as I showed in the example. The main reason is I want to get better readability for myself and other developers who will maintain this code.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…