0
我想輸入一個HTML實體到字段中,當我點擊提交時,讓它有各自的UNICODE和CSS「內容」代碼,但我缺少有些事情:JavaScript:HTML實體轉換器(實體到UNICODE&CSS轉義)
http://jsfiddle.net/nadqnhbc/3/
HTML
<h1>Convert HTML entities into UNICODE & CSS</h1>
<p>Example: Enter &#128038; into the field.</p>
<input type="text" name="ampWhat">
<br>
<input id="submit" type="submit" value="Submit">
<div id="result">
<span id="result-unicode"></span>
<span id="result-css"></span>
</div>
JS
window.addEventListener("DOMContentLoaded", function() {
document.getElementById("submit").addEventListener("click", function() {
var entity = document.getElementById("ampWhat").value;
alert(entity); //Code to convert into UNICODE: U+1F426 OR CSS: "/01F426"
});
});
我迷路了試圖下載它。它可以添加到jsFiddle嗎? – Omar
@Omar jsFiddle鏈接添加。 –