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]);
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.