好的,所以这是我的问题。在.each语句中,它第一次在这个函数中运行,但是当它第二次尝试调用它时,它完全忽略它。可能只是我没有看到一些东西,但我在这里非常困惑。代码如下:
// creates a dialog box
function create_edit(parent) {
var ele = parent;
// Show all the edit elements
ele.find('td.edit').hide();
ele.find('td.save').show();
// CSS for anything needed
$(parent).css({
background:'#5f97c7',
border:'2px solid #000'
});
$("textarea", ele).css('height', '100%');
// Create the edit content in the table row
$(".e_content", ele).each(function(){
$(this).parent().html($(this).html()); // Gets called perfect
});
// Handle the "Save" button for each element in the row
ele.find('td.save a').click(function(e){
e.preventDefault();
alert('clicked'); // this is working meaning I know it's getting called
$(".e_content", parent).each(function(){
console.log('called'); // This statement doesn't get touched. Tried with both ele and parent
});
});
}
首先.each()语句有效,第二个没有。任何试图解决这个问题的帮助将不胜感激。