我正在从' https://randomuser.me/api/'到学校做这个项目。 点击btn新用户将出现在带有编辑和删除按钮的自举卡中。 每个用户都有列表(li): 性别,姓名,电子邮件等。
点击性别值需要将li更改为输入(type =" text")并点击编辑需要保存更改。
答案 0 :(得分:0)
以下是您所需的解决方案:
将以下代码添加到您的js:
$('body').on('click','.edituser' ,function(){
$( ".editing" ).each(function() {
var input = $('<a class="edit" href="#">'+$(this).val()+'</a>');
$(this).replaceWith(input);
});
})
它的作用:
li
按钮时,这将删除所有文本框并使其显示为edit
。