Thursday, 15 July 2010

javascript - edit (append?) a string stored in a jquery variable -



javascript - edit (append?) a string stored in a jquery variable -

i bringing big html string within ajax phone call want modify before utilize on page. wondering if possible edit string if store in variable utilize newly edited string. in success of ajax phone call :

$.each(data.arrangement, function() { var strhere = ""; strhere = this.htmlcontent; //add new content strhere here var content = "<li id=" + this.id + ">" + strhere + "</li>";

htmlcontent key chunk of html code storing in string. has no problem storing string (i checked alert), issue need target div within stored string called .widgtefooter, , add together html (2 little divs). possible jquery? thanks

convert string dom elements:

domhere = $("<div>" + strhere + "</div>");

then can update dom with:

$(".widgetfooter", domhere).append("<div>...</div><div>...</div>");

then do:

var content = "<li id=" + this.id + ">" + domhere.html() + "</li>";

javascript jquery html string variables

No comments:

Post a Comment