在if ($(module).text() === '') {
下有一条if语句,提示我无法上班:
有人可以在这里发现我在做什么错吗?
//button is pressed, this function is called
function submit(button) {
var module = $(button).closest().find('.Table2');
console.log(module);
//gets the text content of a previous text area
var copy = $(button).prev().val();
//checks if the previous text area is empty, if it is, removes it and its container then exits the function
if (copy == "") {
$(button).closest('tr').remove();
return;
}
//replaces all line breaks with <br>
copy = copy.replace(/(?:\r\n|\r|\n)/g, '<br>');
//remove the button and text area and insert text instead
button.parentElement.innerHTML = (copy);
//fall back if all text areas have been submitted empty target the level table and remove DOES NOT WORK
if ($(module).text() === '') {
console.log('help me get to here');
$(module).remove();
}
//wrap all occurances of <br><br> in a span so that height of line breaks can be set
var content = document.getElementById('content').innerHTML;
var breakReplace = content.replace(/<br><br>/g, '<span style="line-height:14px;"><br><br></span>');
document.getElementById('content').innerHTML = breakReplace;
}
答案 0 :(得分:0)
我终于发现问题出在
中的return
if (copy == "") {
$(button).closest('tr').remove();
return;
}
删除return
已解决此问题。
答案 1 :(得分:-1)
$(模块) 确保模块未定义
还需要JQuery选择器('#'和'。')来选择元素