Blogger Information
Blog 31
fans 0
comment 0
visits 14282
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
表单事件,字符串,数组apl
木子木杉
Original
391 people have browsed it

表单事件

  1. function blur(ele) {
  2. event.preventDefault();
  3. event.stopPropagation();
  4. console.log(ele.form);
  5. let email = ele.form.email;
  6. let password = ele.form.password;
  7. if (email.value.length === 0) {
  8. alert("邮箱不能为空");
  9. email.focus();
  10. return false;
  11. } else if (password.value.length === 0) {
  12. alert("密码不能为空");
  13. password.focus();
  14. return false;
  15. } else {
  16. alert("验证通过");
  17. }
  18. }

字符串

let str = “lb学习字符”;
1.length 长度
console.log(str.length);
2.charAt 索引->元素
console.log(str.charAt(4));
3.indexOf 字符->索引
console.log(str.indexOf("习"));
4.search:indexOf一样,但支持正则等
console.log(str.search("学"));
5.concat;字符串拼装
console.log(str.concat("(", "学习", ")"));
6.replace:替换
console.log(str.replace("字符", "js"));
7.slice:子串,忽略结束索引的值
console.log(str.slice(0, 4));
8.substr:子串,只是需要取几个
console.log(str.substr(0, 3));
9.split:str->Array

  1. console.log(str.split());
  2. console.log(str.split(""));
  3. console.log(str.split("", 3));

10.toLowerCase,toUpperCase 大小写转换

  1. console.log(str.toLowerCase());
  2. console.log(str.toUpperCase());

11.与html相关 link:加链接 bold:加粗 anchor:锚点

  1. console.log(str.link("https://php.cn"));
  2. console.log(str.bold());
  3. console.log(str.anchor("url"));
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:api,这个i小写,避免产生不比较的误会
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post