我试图将同一个变量附加两次,但代码似乎只适用于第二个变量。
var test=document.createElement('option');
test.innerHTML='some data';
$('#data1').append(test);
$('#data2').append(test);
我想追加变量测试两次而不创建另一个变量。非常感谢!
最佳答案
尝试放入与下面相同的选择器,
$('#data1, #data2').append(test);
If there is more than one target element, however, cloned copies of the inserted element will be created for each target after the first.
关于javascript - 如何将同一个变量追加两次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12717360/