Javascript 重新排列表的列
我有一个tds具有id的表,我需要重新排列列顺序Javascript 重新排列表的列,javascript,jquery,Javascript,Jquery,我有一个tds具有id的表,我需要重新排列列顺序 $('table tr').each(function() { var tds = $('#Status'); var tdA = $('#Address'); alert(tds.innerHtml); //Here am getting a blank msg tds.remove().insertAfter(tda); //This is what i nee
$('table tr').each(function() {
var tds = $('#Status');
var tdA = $('#Address');
alert(tds.innerHtml); //Here am getting a blank msg
tds.remove().insertAfter(tda); //This is what i need to do
});
使用类的工作示例:
使用ID的工作示例: 另外,您不应该有重复的ID。
仔细检查
“#状态”
不应为”。状态“
$('table tr').each(function() {
var tds = $(this).find('#Status'); //find the child of the row
var tdA = $(this).find('#Address'); //find the child of the row
tds.remove();
$(tds).insertAfter(tdA);
});
请分享你的html。。看起来您的每一行都有
#Status
和#Address
。。。。元素的ID必须是唯一的。如果您选择所有相同的ID,$(“#Status”)
,那么它们可能是重复的。实际上这是一个动态生成的asp Repeater,所以我在每一行中都有它。我的html代码太多了,我如何替换它,如果我将其设为类,我该怎么办?这不可能是正确的!!相同的身份证<代码>$(this.find('.Status')“它在HTML5中是允许的”?你指的是重复的ID吗?不,那不是真的。ID必须是唯一的。这在本例中是正确的…,但您仍然应该避免它@reyaner我不反对,我永远不会这么做:)@undefined该值在元素的主子树中的所有ID中必须是唯一的,从: