使用jQuery更改HTML内容时出错 [英] Error changing html content with jQuery

查看:52
本文介绍了使用jQuery更改HTML内容时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是怎么了?我想用其他内容替换ul内容

What is wrong here? I want replace ul content with other content

$('#carouselselectitem1').click(function() {
$('#foo2').html('<li><div id="lines"></div><div id="tittle">2 PROGRAMEO, LONDRES</div><div id="image"></div><div id="text">LOREM IPSUM XHTML+CSS3 HTTP://WWW.url.com/</div></li>');
});

http://jsfiddle.net/Txyse/

推荐答案

您的小提琴包含mootools而不是jQuery.

Your fiddle includes mootools instead of jQuery.

您的小提琴琴弦中有一个换行符.删除它,或在字符串的第一行末尾添加\,如下所示:(请注意,在下面的第二行代码末尾\)

You have a line break in a string in your fiddle. Either remove it or add a \ at the end of the first line of the string like below: (notice the \ at the end of the 2nd line of code below)

$('#carouselselectitem1').click(function() {
  $('#foo2').html('<li><div id="lines"></div>\
                  <div id="tittle">TITTLE2</div><div id="image"></div><div id="text">TEXT2</div></li>');
                  });

工作演示

这篇关于使用jQuery更改HTML内容时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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