Get raw value of attribute in js

677 Views Asked by At

Here is sample code:

<div id="file" filename="/blahblah-&#1633;.php">AA</div>
<script>
var d = document.getElementById('file').getAttribute('filename');
console.log(d);
</script>

I want to get: /blahblah-&#1633;.php in logs, but above entity is translated to unicode. How to get raw value of attribute in js or jquery?

1

There are 1 best solutions below

0
On

When html file is generated via php, need to escape strings, especially this: htmlspecialchars('/blahblah-&#1633;.php'); In my case it was generated by php.