javascript - 我们如何使用 jQuery 将字符的十进制值添加到属性

标签 javascript jquery html css

我正在尝试使用 jQuery 将摄氏度 值添加到属性。

$("#degree-toggle").attr("value", ℉);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" id="degree-toggle" checked="checked">

最佳答案

 $("#degree-toggle").attr("value", $("<div />").html('&amp;').text());

工作笔: https://codepen.io/todorutandrei/pen/OzGgmM

关于javascript - 我们如何使用 jQuery 将字符的十进制值添加到属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48400881/

相关文章:

javascript - 条件三元运算符给出错误 : Expected an assignment or function call and instead saw an expression when setting a variable

javascript - jquery触摸打洞不工作

javascript - 如何在 HTML 页面中显示图像

javascript - Jquery add class if a corresponding element hasClass 'active'(试图简化我的代码)

javascript - 可疑的 html 脚本,可能是 cookie 窃取器

javascript - 函数使用切片应用参数

javascript - Vuejs 和 Drupal

javascript - Angular 7 : Rxjs behaviour subject subscribe not working on page reload but works in route navigation

jquery - ckeditor 和粘贴文本事件

javascript - "' null ' is null or not an object"IE 错误