Vektor Unbreakable
Vektor Unbreakable

Reputation: 71

Error changing html content with jQuery

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/

Upvotes: 1

Views: 107

Answers (3)

sachleen
sachleen

Reputation: 31131

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

Upvotes: 4

Nandu
Nandu

Reputation: 3126

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/

Upvotes: 2

PassKit
PassKit

Reputation: 12581

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

Upvotes: 1

Related Questions