1

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/

asked Jan 14, 2013 at 2:56
2
  • 1
    possible duplicate of error code with html jQuery Commented Jan 14, 2013 at 3:04
  • So... why did you ask the same question twice within one hour? Commented Jan 14, 2013 at 3:07

3 Answers 3

4

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>');
 });

Working demo

answered Jan 14, 2013 at 3:01
Sign up to request clarification or add additional context in comments.

1 Comment

thanks!!!! Work fine. and yes, sachleen, i'm new here and i must wait a lot of time for write. Sorry.
2

Try this,

$('#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>');
 });

http://jsfiddle.net/Txyse/8/

answered Jan 14, 2013 at 3:05

1 Comment

When answering please make sure to explain what you changed in the code.
1

There are a number of problems with your fiddle.

  1. jQuery is not loaded
  2. Your Javascript has a line break in a string
  3. The click event needs to be attached after the document is loaded

This fiddle works

$(document).ready( function(){
 $('#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>');
 });
});
answered Jan 14, 2013 at 3:05

2 Comments

@sachleen - true, but it is also not uncommon for beginners to miss point 3 and we have no knowledge of the rest of the OP's code.
Oops, I accidentally deleted my comment. For @PassKit's reply to make any sense I had said jsFiddle takes care of #3

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.