博客列表 >12月23日jQuery表单验证-九期线上班

12月23日jQuery表单验证-九期线上班

WJF
WJF原创
2019年12月25日 14:38:41972浏览

jQuery表单验证


  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>jQuery增添元素</title>
  6. <script src="jquery-3.4.1.min.js"></script>
  7. <style>
  8. #phpcn{
  9. background-color: #0C9A9A;
  10. border-radius: 2px;
  11. padding: 20px;
  12. }
  13. button{
  14. background-color: #0E9A00;
  15. border: 0;
  16. border-radius: 2px;
  17. padding: 10px;
  18. margin-top: 5px;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <div>
  24. <p id="phpcn">【PHP中文网-33703259@qq.com】</p>
  25. </div>
  26. <button type="button" onclick="appends()">[appends]在匹配元素末尾处插入参数内容</button>
  27. <button type="button" onclick="appendTos()">[appendTo]将匹配的元素插入到目标元素的最后面</button>
  28. <button type="button" onclick="prepends()">[prepend]将参数内容插入到每个匹配元素的前面</button>
  29. <button type="button" onclick="prependTos()">[prependTo]将所有元素插入到目标前面(元素内)</button>
  30. <button type="button" onclick="afters()">[after]在匹配元素后面插入指定内容</button>
  31. <button type="button" onclick="befores()">[before]在匹配元素前面插入指定内容</button>
  32. <button type="button" onclick="insertAfters()">[insertAfter]在目标元素后面插入匹配的元素</button>
  33. <button type="button" onclick="insertBefores()">[insertBefore]在目标元素前面插入匹配的元素</button>
  34. <button type="button" onclick="replaceWiths()">[replaceWith]用提供的内容替换匹配元素并删除原本元素</button>
  35. <button type="button" onclick="emptys()">[empty]移除匹配元素的子节点</button>
  36. <button type="button" onclick="removes()">[remove]移除匹配元素</button>
  37. </body>
  38. <script>
  39. //移除匹配元素
  40. function removes() {
  41. $('#phpcn').remove();
  42. }
  43. //移除匹配元素的子节点
  44. function emptys() {
  45. $('#phpcn').empty();
  46. }
  47. //用提供的内容替换匹配元素并删除原本元素
  48. function replaceWiths() {
  49. $('#phpcn').replaceWith('<p id="phpcn">【QQ:33703259】</p>')
  50. }
  51. //在目标元素前面插入匹配的元素
  52. function insertBefores() {
  53. $('<p id="phpcn">888</p>').insertBefore('#phpcn');
  54. }
  55. //在目标元素后面插入匹配的元素
  56. function insertAfters() {
  57. $('<p id="phpcn"> 999</p>').insertAfter('#phpcn');
  58. }
  59. //在匹配元素末尾处插入参数内容
  60. function appends() {
  61. $('#phpcn').append('666');
  62. }
  63. //将匹配的元素插入到目标元素的最后面
  64. function appendTos() {
  65. $('<p id="phpcn">666</p>').appendTo('#phpcn');
  66. }
  67. //将参数内容插入到每个匹配元素的前面
  68. function prepends() {
  69. $('#phpcn').prepend('WDM');
  70. }
  71. //将所有元素插入到目标前面(元素内)
  72. function prependTos() {
  73. $('<p>NEW</p>').prependTo('#phpcn');
  74. }
  75. //在匹配元素后面插入指定内容
  76. function afters() {
  77. $('#phpcn').after('<p id="phpcn">php</p>');
  78. }
  79. //在匹配元素前面插入指定内容
  80. function befores() {
  81. $('#phpcn').before('<p id="phpcn">phpcn</p>');
  82. }
  83. </script>
  84. </html>

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议