简体   繁体   English

附加 document.body 的 innerHTML 后,Jquery 的日期选择器不起作用

[英]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.

相关问题 添加到document.body的innerHTML会导致jQuery .on()找不到它的目标 - Adding to innerHTML of document.body causes jQuery .on() to not find its target 替换主体后,jQuery ui datepicker不起作用 - jquery ui datepicker doesn't work after body replacement 为什么$(window [&#39;iframeName&#39;]。document.body).html()在我更改.attr(&#39;src&#39;)时不起作用 - why $(window['iframeName'].document.body).html() doesn't work when i change .attr('src') 添加InnerHTML时,jQuery DatePicker不起作用 - Jquery DatePicker doesn`t work when adding InnerHTML jQuery的触发方法在准备好文档后无法正常工作 - jQuery's trigger method doesn't work properly on document ready $ {document).ready中的jQuery的removeAttr函数不起作用 - jquery's removeAttr function inside $(document).ready doesn't work 附加正文后的 YUI,on(&#39;click&#39;) 甚至不起作用 - YUI after appending body, on('click') even doesn't work 附加<a>和</a> <a><img></a> <a>to document.body删除href和src</a> - Appending <a> and <img> to document.body removes href and src 将PHP回声放入按钮的innerHTML中不起作用 - Putting PHP echo into a button's innerHTML doesn't work 尝试更改元素的DOM的属性,但是使用document.body.innerHTML + =后,更改被忽略。 如果顺序切换,一切正常 - Trying to change an element's DOM's properties, but changes ignored after I use document.body.innerHTML +=. If order switched, things work fine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM