I have following html (html may be vary) in php variable. I have used append function (jQuery) for adding this html but always fail…… (due to not properly formated html). I’ve tried htmlentities,html_entity_decode and htmlspecialchars function for formating html but not success…. 🙁 Any-buddy know how to escaped this html. (either by PHP or jquery and how???? appreciate for your answer)
<tr>
<td class='paramlist_key'>
<label id='ID' for='FOR' class='CLASS'>*AT</label>
</td>
<td class='CLASS_A'>
<select id="19" name="Name" class="cc" title="" style="" size="">
<option value="" >Select below</option>
<option value="A" selected="selected">A</option>
<option value="B">B</option>
</select>
<span id="mm" style="display:none;"> </span>
</td>
</tr>
You need to convert the HTML to a valid JavaScript string, which means it has to be 1 line and all “-quotes or ‘-quotes must be escaped, depending on which your outer style will be in the final JS. So something like:
Or even easier, just
json_encode()it and omit the quotes in the JS script itself asjson_encode()will add those.