我有
<div><a class='link' href='index.php' data-container='target'>Load</a></div>
<div class='target'></div>
我需要编写 jquery 代码,将 href url 加载到数据容器属性
$('.link').click(function(e) {
e.preventDefault();
$(this.data-container).load(this.href);
});
最佳答案
像这样使用数据
:
$('.link').click(function(e) {
e.preventDefault();
$('.' + $(this).data('container')).load(this.href);
});
关于jquery .load() 动态定位的 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11268639/