[英]Jquery's datepicker doesn't work after appending document.body's innerHTML
Example:例子:
1) go to www.hotwire.com and confirm that the datepicker for check-in and check-out works 1) 访问 www.hotwire.com 并确认签入和签出的日期选择器有效
2) open up the console and type in document.body.innerHTML += "" 2) 打开控制台并输入 document.body.innerHTML += ""
3) datepicker no longer works 3)日期选择器不再有效
I'm not sure why this is... if you create the element using document.create and append it using document.body.appendChild, the datepicker still works...我不确定这是为什么...如果您使用 document.create 创建元素并使用 document.body.appendChild 附加它,则日期选择器仍然有效...
When you call el.innerHTML += ""
, you are essentially doing el.innerHTML = "";el.innerHTML = thehtml
, which causes all element data and events to be unbound.当您调用
el.innerHTML += ""
,您实际上是在执行el.innerHTML = "";el.innerHTML = thehtml
,这会导致所有元素数据和事件未绑定。 That's why plugins and javascript stops working.这就是插件和 javascript 停止工作的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.