开发者

IE8 & JS clone and prependTo does not work

I'm using the Internet Explorer to execute an JS application. Part of this app开发者_运维问答lication is to copy/clone an inputfield (including autocompletion functionality).

For that, I simply clone the input existing field:

field=$("#Searach_Field").clone().prependTo('#New_form');   //clone Element
field.attr('id','New_Search_Field');    //assign new ID to the input field.

This code works very well on firefox: the input field is cloned and also the auto completion works on the new input field.

But at the IE 8: there is no input field! It looks like clone() or prependTo is not executed.

Thank you.


Try to unchain the calls

field=$("#Serach_Field").clone();
field.attr('id','New_Search_Field');
$('#New_form').prepend(field);

There seem to have a typo in #Serach_Field.


I found the answer:

"#Serach_Field" is added to the page "READY" position of the document, while the clone() runs after loading the end (position:END) of the application/document. That means: "#Serach_Field" does not exist at the time clone() is executing.

It looks like, this is not a problem for the firefox. Maybe the firefox is slower in processing the page, than the IE.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜