Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用jQuery的加载功能
我可以写:$('#somediv').load('somefile.html #aSpecificDivinThatPage');
$('#somediv').load('somefile.html #aSpecificDivinThatPage');
现在我想在 html 页面中有一个变量作为源 div,我该如何写出来?
您可以只使用普通的字符串连接:
var div = '#aSpecificDivinThatPage'; $('#somediv').load('somefile.html ' + div);
您的意思是要从源 div 复制 html 并将其放入另一个 div?
$("#destinationDiv").html($("#sourceDiv").html());