2012-12-15 38 views
0

我已經將div的html內容複製到了javascript中的變量中。現在我想把title屬性的值放到TD標籤的內容中,無論哪個類都是彈出的。所以我創建了下面的代碼。但它並沒有幫助..在jquery中查找帶有特定條件的對象變量的標籤

var tmpDiv = document.createElement("div"); 
tmpDiv.setAttribute("style","display:none"); 
$(tmpDiv).html($('#'+divid+" .scrollTableContainer").html()); 

$(tmpDiv+ 'td .popup').each(function(index,value) { 
    $(this).html($(this).attr('title')); 
}); 
+0

嗨,夥計那裏是'VAR divid' –

回答

0
$(tmpDiv).find('td.popup').each(function(index,value) { 
    $(this).html($(this).attr('title')); 
}); 

在你的代碼tempDiv是JavaScript對象,所以tempDiv + 'td.popup' 是不允許的。 其次,如果你需要找到td與類彈出刪除td和.popup之間的空間

0

您試圖連接一個DOM對象和一個字符串來創建一個選擇器。你不能將字符串和對象

將更有意義使用jQuery的所有代碼

var tmpDiv=$('<div>').hide().html($('#'+divid+" .scrollTableContainer").html()); 

tmpDiv.find('td.popup').each(function(index,value) { 
    $(this).html($(this).attr('title')); 
}); 
相關問題