如何使用jQuery创建多个HTML元素? [英] How to create multiple HTML elements with jQuery?

查看:99
本文介绍了如何使用jQuery创建多个HTML元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的是使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆