javascript - JQuery(HtmlString) returns multiple elements -
var $fragment = $("<div> <div id=\"title\" class=\"subheader\"></div></div><div> <div id=\"leftmenu\"></div><div id=\"formdata\" class=\"databox\" data-fld=\"formdata\"></div></div><div> <div id=\"okbutton\"></div> <div id=\"cancelbutton\"></div> <div id=\"actionmenu\"></div></div>"); $("#x").text($fragment.length);
see fiddle ...
http://jsfiddle.net/paull3876/268bt/
... loading jquery object html string, creates array 3 or 5 elements. 5 in visual studio, , 3 in jsfiddle. think difference visual studio version has line feeds.
however line feeds, or whatever causing it, might important, e.g. in tooltip "title", so, i'd prefer have html preserved , not replaces etc on it.
how can html load single element, $fragment.length = 1 , single fragment element contains elements expressed in html string ?
thanks
just wrap div.
javascript jquery html
No comments:
Post a Comment