i need change span tag img tag in run time.
this html block:
<body onload="mediainputfilter ()"> <section data-role="page" data-theme="ams"> <section data-role="header" > <h1>header ssssssssssssssssssssssssssssss sssssssssssssssssssssss ssssssssssssssssssssssssss ssssssssssssssss ssssssssssss</h1> </section> <section data-role="conents" id="mycontent" > <p>loruim epsum haha </p>\n<p>hehe told u </p>\n<ol class="starpasspro-upper-alpha_ol">\n<li>gasdfg</li>\n<li>sdfffasd</li>\n<li>asdfffasdf</li>\n<li>asdfasdfasdfasd</li>\n</ol>\n\n<table class="table_with_header lsm-tableclass-styles">\n<tbody>\n<tr>\n<td class="lsm_table_heading_1">description</td>\n<td class="lsm_table_heading_1">amount</td>\n</tr>\n<tr>\n<td>gross salary</td>\n<td> xxxx</td>\n</tr>\n<tr>\n<td>less: income tax (£35,000 x 25%)</td>\n<td> xxxx</td>\n</tr>\n<tr>\n<td>less: social security tax (£50,000 x 9%)</td>\n<td> xxxx</td>\n</tr>\n<tr>\n<td>net earnings</td>\n<td> xxxx</td>\n</tr>\n<tr>\n<td>employer’s contribution on social security<br>(£50,000 x10.5%)</td>\n<td> xxxx</td>\n</tr>\n</tbody>\n</table>\n\n <p><span data-lscp-resource-mimetype="image/png" data-lscp-resource-id="00001"></span></p> </section> <section data-role="footer"> <p>footer</p> </section> </section> after html executed span tags need converted in img tag automatically.
i tried other way round did work in scenario not working.
here js (this written in jquery)
function mediainputfilter(){ $($("section[data-role='conents']").html()).find("span[data-rcb-resource-mimetype^=image]").each(function (i,node) { var imgnode = $(node); var src = '../images/00001.png'; var spannode = $("<span/>"); spannode.attr("data-rcb-resource-mimetype", imgnode.attr("data-rcb-resource-mimetype")); spannode.attr("data-rcb-resource-id", imgnode.attr("data-rcb-resource-id")); spannode.attr("src", src); imgnode.after(spannode); imgnode.remove(); }); } any please tell me wrong or if have solution i'm open.
your changes not persisting because making changes node destroyed code runs.
see http://learn.jquery.com/javascript-101/scope/
solution:
replace
$($("section[data-role='conents']").html()).find("span[data-rcb-resource-mimetype^=image]").each(function (i,node) { with
$("section[data-role='conents']").find("span[data-rcb-resource-mimetype^=image]").each(function (i,node) {
Comments
Post a Comment