如何使用jQuery创建多个HTML元素? [英] How to create multiple HTML elements with jQuery?
问题描述
我想要做的是使用jQuery创建一个表分页器控件。
它包含很多链接和跨度。我已经设法用纯字符串连接做到这一点,但我不能相信jQuery不能使这更优雅。
我不能在这里使用jTemplates,因为这个世代有相当多的过程逻辑。
问题:有没有办法创建一个HTML元素数组与jQuery和附加到一些容器?
谢谢。
$(' First Element ')。add($(' Second Element '))。appendTo($('body'))
What I'm trying to do is to create a table pager control using jQuery. It contains lots of links and spans. I've managed to do this with plain string concatenation, but I can't believe that jQuery can't make this more elegant. I can't use jTemplates here since the generation has quite a bit of procedural logic.
Question: is there a way to create an array of HTML elements with jQuery and append them to some container?
Thanks.
$('First Element').add($('Second Element')).appendTo($('body'))
这篇关于如何使用jQuery创建多个HTML元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!