标签:div jquery 绑定 OLE doctype inpu btn child content
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <form> <input type="text" name="user" value=""> <input type="text" name="pass" value=""> <input type="button" id="btn"> </form> </body> <script src="../jquery.js"></script> <script> var obj = { user:"admin", pass:123, a:10 } console.log(obj); //{user: "admin", pass: 123, a: 10} console.log($.param(obj)) // user=admin&pass=123&a=10 $("#btn").click(function(){ console.log($("form").serialize()) //user=自己输的值&pass=自己输的值 必须要设置name }) </script> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <input type="button" id="btn" value="点击"> </body> <script src="../jquery.js"></script> <script> 上面写的html等价于 $(‘<input type="button" id="btn" value="点击">‘) $("#btn").click(function(){ //绑定事件 console.log(2); }) var ipt = $("#btn").clone(true); //克隆不克隆事件,如果需要克隆事件需要在后面clone写个true $("body").append(ipt); var div = document.createElement("div") // obox.innerHTML = div; × // [object Object] obox.appendChild(div) $("body").html($("<div>")) × $("body").html("<div>") //可以直接写元素就创建,input被替换成了·div $("body").append($("<div>")) //插入式创建,创建在script标签后面。 // clone出的元素,与创建出的元素类型相同,意味着,clone出的元素必须通过append方法插入 </script> </html>
标签:div jquery 绑定 OLE doctype inpu btn child content
原文地址:https://www.cnblogs.com/hy96/p/11560115.html