1
嘗試將數據相對添加到我的javascript .attr原來這裏是ATTR:數據相對
link.attr('href',obj.images.standard_resolution.url);
這裏是我試過:
link.attr('href data-rel="lightframe"',obj.images.standard_resolution.url);
我也試圖讓所有的一環節包括,但沒有運氣:
$('a').attr('data-rel', 'lightframe');
這甚至可能嗎?如果是這樣,那麼使用正確的語法是什麼?我在http://api.jquery.com/attr/有一個很好的閱讀,但沒有解決我的問題?
編輯:標記位置:
function ProcessData(response){
if(response != null){
var ul = $('<ul/>');
ul.attr({'class': tag_name});
$(response.data).each(function(index,obj){
if(index == 20)
return response.pagination.next_url;
var link = $('<a/>'), image = $('<img/>'), li = $('<li/>');
image.attr({'src': obj.images.standard_resolution.url,
'width':thumb_dimension,'height': thumb_dimension});
link.attr({'href' : obj.images.standard_resolution.url,'data-rel' : 'lightcase'});
image.appendTo(link);
link.appendTo(li);
if(include_username){
$('<div class="username">'+obj.from.username+'</div>').appendTo(li);
}
if(include_caption){
$('<div class="caption">'+obj.caption.text+'</div>').appendTo(li);
}
// Append the image (and text) to the list
ul.append(li);
});
// Append the list to the given div
$(div_to_add_pics).append(ul);
// make url correlate to the next set of data
url = response.pagination.next_url;
}
};
顯示您的標記。 –
@TusharGupta這夠了嗎?或者我應該包括完整的'功能' – SethCodes
你怎麼在圖像屬性中使用正確的語法... –