[英]Need to correctly render html tags
I know this question might have been asked before, but I have not yet found a way to solve my issue. 我知道以前可能会问过这个问题,但是我还没有找到解决问题的方法。
On this page , if you click on Webster on the left, you can see the part that says <b>test html</b><br />
. 在此页面上 ,如果单击左侧的Webster,则可以看到
<b>test html</b><br />
。 I need that to be rendered correctly on the page. 我需要将其正确显示在页面上。
Here is the data that gets saved to the database: <b>test html</b><br />
以下是保存到数据库中的数据:
<b>test html</b><br />
And here is how I display it on the page (the problematic area is store_details
): 这是我如何在页面上显示它(有问题的区域是
store_details
):
contentPane.html('');
html = '<div onclick="showStoreDetails(\'item_store_'+j+'\')" class="custom-location-wrapper"><div class="wk_st_product_gen" id="item_store_'+ j +'" onmouseout="offhighlightMarker('+j+')" onmouseover="highlightMarker('+j+')" onclick="showcontent(\''+store_title+'\',\''+store_address+'\',\''+store_link+'\',\''+j+'\')"><input type="hidden" class="position" id="'+str_dis;
html+= '"><input type="hidden" id="str_lati" value="'+store_latitude;
html+= '"><input type="hidden" id="str_longi" value="'+store_longitude;
html+= '"><div class="store_info"><img alt="store" src="<?php echo HTTP_SERVER;?>image/webkul-store-locater/'+store_image;
html+= '"> <div class="store_address"><div class="store_title">'+store_title;
html+= '</div><div class="store_details"><p class="store_addressline" >'+store_address;
html+= '</p><p class="store_locality">'+store_local;
html+= '</p><p class="store_distance">'+store_distance;
html+= '</p><p>'+store_details;
html+= '</p></div></div></div></div>';
html+= '<style>#alert_red{display:none;}</style>';
contentPane.append(html);
Take a look at the Lo-Dash library (based on underscore). 看一下Lo-Dash库(基于下划线)。 It has an _.unescape method that does this:
它具有_.unescape方法,可以执行以下操作:
http://lodash.com/docs#unescape http://lodash.com/docs#unescape
html+= '</p><p>'+_.unescape(store_details);
You can just use html_entity_decode
in PHP to decode you data before retrieving it. 您只能在PHP中使用
html_entity_decode
对数据进行解码,然后再进行检索。
us3.php.net/html_entity_decode us3.php.net/html_entity_decode
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.