Reputation: 25
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]);
Upvotes: 1
Views: 82
Reputation: 337701
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>
Upvotes: 2