Skip to content Skip to sidebar Skip to footer

How To Append The Data Using Jquery?

I need to add the value into the span using dom. But now i am using string manipulation. how to change this into the dom or append the value . i need to get the return value in htm

Solution 1:

Define layer.id as some text and this will get replace in all span element content

$.each($("span"),function(){
$(this).html(layer.id);
});

Thanks

Solution 2:

You can append like following :

$('.ClassName').append('<p>Test</p>');

Solution 3:

$('#id').after('<p>Test</p>');
$('#id').before('<p>Test</p>'); 

Solution 4:

Try with this:

$("<li class='" + liClass + "'>" + preElement + 
  "<label for='" + layer.id + "'>" + layer.name + "</label>").appendTo('ul.class'); 
                                                               //----------^^^^^ // use the id // or class of //the specific ul

use appendTo() instead return and append it to your element.

(as i see you are returning li then append it to the ul)

Post a Comment for "How To Append The Data Using Jquery?"