Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting HTML "title" attribute with JS doesn't render &

What is the proper way to use an ampersand in the title attribute? I would have assumed that you should use &, but it gives different behavior depending on whether it was set in the original HTML or modified with JS.

Tooltip rendering in Chrome (Version 47.0.2526.106 (64-bit)) and Safari (Version 9.0.2 (11601.3.9)):

enter image description here with JS

https://jsfiddle.net/davegaeddert/femm9b96/

like image 425
davegaeddert Avatar asked Oct 18 '22 17:10

davegaeddert


1 Answers

& means & in HTML.

& means & when you are directly manipulating the DOM using a DOM API.

If you aren't writing HTML, don't use HTML entities.

like image 71
Quentin Avatar answered Oct 21 '22 06:10

Quentin