Alt attribute encoding with JavaScript

后端 未结 4 1603
深忆病人
深忆病人 2020-12-03 22:07

Html entities must be encoded in alt attribute of an image in HTML page. So

\"A
         


        
4条回答
  •  时光取名叫无心
    2020-12-03 22:57

    JavaScript has its own system for escaping special characters in strings:

    document.getElementById('formula').alt = 'A \u2192 B';
    

提交回复
热议问题