当前第2页 返回上一页
1 2 3 4 5 6 | var country = "中国" ;
var table = "<table border=\"1\" style=\"width:100%;\">" ;
table += "<caption>国家信息列表</caption>" ;
table += "<thead><tr><th>ID</th><th>Name</th></tr></thead>" ;
table += "<tbody><tr><td>1</td><td>" +country+ "</td></tr></tbody>" ;
table += "</table>" ;
|
2.采用单引号
1 2 3 4 5 6 | var country = "中国" ;
var table = '<table border="1" style="width:100%;">' ;
table += '<caption>国家信息列表</caption>' ;
table += '<thead><tr><th>ID</th><th>Name</th></tr></thead>' ;
table += '<tbody><tr><td>1</td><td>"' +country+ '"</td></tr></tbody>' ;
table += '</table>' ;
|
3.采用es6的模板字符量(不过我喜欢用模板字符串来称呼这个。。。)
输出变量的值,比如上面说到的country=“中国”,那么要怎么才可以输出中国这个值呢?
其实可以用占位符来代表${ }
,括号中间的部分就写上你要输出变量所代表的变量名称。
1 2 3 4 5 6 | var country = "中国" ;
var table = `<table border= "1" style= "width:100%;" >`;
table += `<caption>国家信息列表</caption>`;
table += `<thead><tr><th>ID</th><th>Nane</th></tr></thead>`;
table += `<tbody><tr><td>1</td><td>${country}</td></tr></tbody>`;
table += `</table>`;
|
相关免费学习推荐:JavaScript(视频)
以上就是jquery怎么输出html代码的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
详解7款绚丽的jQuery/html5动画及源码
jQuery不兼容低版本ie浏览器怎么办
jQuery与ajax的区别是什么
jQuery怎么让checkbox不选中?
jQuery中easyui是什么
jQuery如何查看元素是否绑定事件
jQuery easyui 乱码怎么办
jQuery怎么移除css样式
jQuery怎么获取元素
jQuery怎样判断是否是字符串
更多相关阅读请进入《jQuery》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » jquery怎么输出html代码