1

I have a problem with > and jquery datatable shows '>' fine but when I click on the row I get the character > and I'm desperate.

Any solution?

$('#sample tbody').on('click', 'tr', function() {
    //console.log(table.row(this).data());
    $(".modal-bodya div span").text("");
    $(".new span").text(dataTable.row(this).data()[2]);
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339

1 Answers1

2

The issue is because you're using text(), which does not encode HTML entities. To get the output you expect use html() instead.

let value = 'foo > bar';

$(".text span").text(value);
$(".html span").html(value);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div class="text">Text: <span></span></div>
<div class="html">HTML: <span></span></div>
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339