简体   繁体   中英

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

2) open up the console and type in document.body.innerHTML += ""

3) datepicker no longer works

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...

When you call el.innerHTML += "" , you are essentially doing el.innerHTML = "";el.innerHTML = thehtml , which causes all element data and events to be unbound. That's why plugins and javascript stops working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM