2009年7月29日 星期三

[原創] jquery clone 修正無法 copy select 已選擇的值.

javascript:
n = $('#table'); //要copy 的id
temp = n.clone(true);
temp.find('select option').each(function(){
if ( $('#sel option:selected').val() == $(this).val() ) $(this).attr('selected','selected');
});

居然寫了這麼長, 應該還有高手可以縮更短的吧...

這邊有 無法clone 的例子: http://fligtar.com/testcases/jquery-clone.html

【下列文章您可能也有興趣】

沒有留言: