0

Database text values will be displayed on HTML page and once the user clicks the paragraph JQuery an alert message will pop up with database values.

But the paragraph contains " and '. When passing article-data to JQuery it will pass text up to first ' in the paragraph. How to solve this without doing any change in MySQL database?

<?php
    foreach ($data as $add) {
    echo "<div>";      
    echo "<p class='target' article-data='$add->p_content' >" . $add->p_id . $add->p_content . "</p>";
    echo "</div>"; 
}
?>

<script>
    //Display dialog box when mouse click 
    $( ".target" ).click(function() { 
       alert($(this).attr("article-data"));
    });       
</script>
stj
  • 9,037
  • 19
  • 33
Geeth Welagedara
  • 614
  • 1
  • 8
  • 24

0 Answers0