Jquery
attribute contents a paragraph which has " ' sings. When i want to alert
it output contents only up to first " sing in the paragraph. others are missing. why and how to avoid that. In php
i solved it using htmlspecialchars
function. What is the function in Jquery
to do it?
updates : The attribute values comes from mysql database. sample string as follows
One person height is 5'5" the other one is 12" less then him.
<div id="dataview" class="col-md-9">
</div>
$(window).load(function() {
$.ajax({
url: '<?php echo base_url(); ?>' + 'main/data',
dataType: "JSON",
type: "POST",
success: function(retdata) {
$.each(retdata, function(i) {
var content = '<div class="target btn-default" prop-content="' + retdata[i].content + '">' + retdata[i].content;
$("#dataview").append(content);
});
}
});
});
//Using event delegate
$(function() {
$("#dataview").on('click', ".target", function() {
var prop = $(this).attr("prop-content");
alert(prop);
});
});