我正在尝试删除具有学生姓名的课程。在此之后,我试图附加一个输入字段来替换名称。当我使用0或1等时它工作正常。我尝试过使用Parseint,但这也无济于事。以下是我的代码
的示例$(document).ready(function(){
$(".Edit-item-Pencil").click(function(){
var parentIndex = $('.Edit-item-Pencil').index(this);
var parentText = $('.Edit-item').eq(parentIndex).text();
var test = parentIndex;
$('.Edit-item').eq(parentIndex).hide();
$('.Edit-item' ).eq(parentIndex).removeClass( ".Edit-item" );
$(".input-edit:eq(" + test + ")").append( '<input class="form-control" id="name" name="Student-text" type="text"/>' );
});
})
<li> <b>Student Name</b> <a href = "#" class = "Edit-item">Name <div class = "input-edit"></div> <span class = "Edit-item-Pencil"><i class="fas fa-edit"></i></span> </a></li>
<li> <b>Student Email </b> <a href = "#" class = "Edit-item">My Email<div class = "input-edit"></div> <span class = "Edit-item-Pencil"><i class="fas fa-edit"></i></span> </a></li>
<li><b> Module 0 </b> <a href = "#" class = "Edit-item">My grade<div class = "input-edit"></div> <span class = "Edit-item-Pencil"><i class="fas fa-edit"></i> </span> </a></li>
答案 0 :(得分:0)
@Query("SELECT 1 FROM MyTable")
public int testConnection();
<li> <b>Student Name</b> <span class="Edit-item">Name</span> <span class = "Edit-item-Pencil">Edit</span></li>
<li> <b>Student Name</b> <span class="Edit-item">Email</span> <span class = "Edit-item-Pencil">Edit</span></li>
<li> <b>Student Name</b> <span class="Edit-item">Test</span> <span class = "Edit-item-Pencil">Edit</span></li>
您可以通过$(document).ready(function(){
$(".Edit-item-Pencil").click(function(){
$(this).parent("li").find("span.Edit-item").html('<input class="form-control" id="name" name="Student-text" type="text"/>')
});
})
轻松完成此操作,我还必须更改您的HTML代码,因为您在不推荐的标记中使用了div。请查看工作示例fiddle