开发者

PrototypeJS - Changing Elements Within HTML Variable

开发者 https://www.devze.com 2023-04-06 17:15 出处:网络
Is there a way to make calls within an HTML variable that is not in the DOM?For example, my code copies an existing row and then places it in the DOM.The problem is, I need to change some things withi

Is there a way to make calls within an HTML variable that is not in the DOM? For example, my code copies an existing row and then places it in the DOM. The problem is, I need to change some things within it. Code like:

newHTML = $$('.someRow')[0].innerHTML;
//Need to change form fieldName1 to fieldName2 in the开发者_StackOverflow newHTML variable, etc
$(this).up(1).insert({ 
   before: newHTML 
});

Right now I am changing things after, but it makes it difficult when there is a radio button that retains the same fieldname and changes the checked value of the original row.

Thanks.


You should be able to do this if you clone the node that you want to insert. e.g.

var newNode = $$('.someRow')[0].clone(true);

The cloned node is not inserted into the DOM until you insert it so you can manipulate it in whatever way you choose before doing so, its just a prototype Element.

0

精彩评论

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