Display a WordPress shortcode with line breaks with jQuery or pure Javascript
-
I am trying display a wordpress shortcode with jQuery html() function.
When I put the shorcode, it shows a Google map. The shortcode is
[locations_map scope="2015-09-01,2015-09-30"]
It displays the folowing html:
<div class=”em-location-map-container” style=’position:relative; background: #CDCDCD; width: 100%; height: 500px;’>
<div class=’em-locations-map’ id=’em-locations-map-8ec52′ style=”width:100%; height:100%”>Loading Map….</div>
<div class=’em-locations-map-coords’ id=’em-locations-map-coords-8ec52′ style=”display:none; visibility:hidden;”>{“width”:”100%”,”height”:”500px”,”em_ajax”:true,”query”:”GlobalMapData”,”random_id”:”8ec52″}</div>
</div>It display html code with line breaks
When I try to display the map with:
jQuery(‘#id-map’).html(‘[locations_map scope=”2015-07-01,2015-07-30″]’);
});It shows the html code, but it has linebreaks then I get an error such as SyntaxError: missing ) after argument list due to linebreaks. How can I show the html of the shortcode in a single line?
- The topic ‘Display a WordPress shortcode with line breaks with jQuery or pure Javascript’ is closed to new replies.