[javascript]编码&i字符串格式化&nput历史记录&清空模态框

js中编码问题

https://www.haorooms.com/post/js_escape_encodeURIComponent

我在前端js添加时候创建dom时候,有汉字,发现是乱码就研究了下

针对字符编码

 javascript:escape("\u6625\u8282");
//输出 "%u6625%u8282"

 javascript:unescape("%u6625%u8282");
//输出 "春节"

 javascript:unescape("\u6625\u8282");
//输出 "春节"

针对url汉字编码

encodeURIComponent()相比encodeURI()要更加彻底。
decodeURI()

js字符串格式化

我在前端js添加时候创建dom时候, 发现能不能字符串拼接,而非创建对象的方式来搞.

https://blog.csdn.net/duwen90/article/details/50570406

var s="my name is %s, I'm %s years old, and I have %s brother."
s=s.format("wendy",24,2)
结果s为:"my name is wendy, I'm 24 years old, and I have 2 brother."

禁止浏览器记录 文本框之前输入过的内容

https://baijunyao.com/index.php/article/17

<input class="text" autocomplete="off" type="text" name="word" value="输入商品名称">

每次模态框jq清空

这是在添加时候,弹出模态框总是有上一次记录.
https://www.formget.com/jquery-reset-form/

$(selector)[0].reset();

猜你喜欢

转载自www.cnblogs.com/iiiiiher/p/9206494.html
今日推荐