Is it possible to append html code in parts via JQuery?
- by phpheini
I am trying to append li elements coming from a php file with JQuery. Problem is that the html code needs to be seperately appended to different html IDs according to the key value. Unfortunately as I understood append() can only append correct html with all elements closed. Otherwise it will automatically close the tags. The following code will NOT work as dval contains code like <div><li class="some">Some value</li> and append() will make <div><li class="some">Some value</li></div> out of it. So I was wondering whether there is another way, maybe a function other than append() to be able to append html parts?
$.each(obj, function(key,val)
{
$.each(obj[key], function(key, dval)
{
if(key == "text")
{
$("#" + key).append(dval);
}
})
});