1
具有if元素上存在與類名「異步」我試圖找出其中的數據應該被包裹,但沒有任何結果給定的數據屬性,通過AJAX加載數據這個簡單的jQuery插件jQuery的數據屬性
(function($) {
$.fn.asyncLoader = function(options) {
var $self = this;
var settings = $.extend({}, options);
var attributes = [];
return this.each(function(i) {
attributes = $(this).data();
$.each(attributes, function(key, value) {
if (key == 'load') {
if (value.target) {
var el = $('.async').filter('[data-load = \'{"target" : "' + value.target + '" }\' ]');
el.load(value.target)
}
}
});
});
};
}(jQuery));
標記看起來像
<div class="async" data-load = '{"target": "/my-target"}'></div>
如何找到父元素?
很酷謝謝你最後很方便,正在工作! – deroccha
太棒了!很高興幫助。如果您滿意,請接受答案。 –