如何删除选定的输入?
我用jQuery创建了输入标签
$('#con').append('<input type="text">'+ '<span class="del">delete</span>');
我有创建按钮。
当我单击按钮3次。输入也会创建3次。 如您所见;我用del class设置了span标签;输入标签后。当我单击范围标记时,我想要。标记(输入)已单击“删除”。 我怎样才能做到这一点? 注意:我没有输入的ID。
如何删除选定的输入?
我用jQuery创建了输入标签
$('#con').append('<input type="text">'+ '<span class="del">delete</span>');
我有创建按钮。
当我单击按钮3次。输入也会创建3次。 如您所见;我用del class设置了span标签;输入标签后。当我单击范围标记时,我想要。标记(输入)已单击“删除”。 我怎样才能做到这一点? 注意:我没有输入的ID。
You have the id selector
#con
:You can do it like this: As the delete button is added dynamically, you have to delegate the
click()
event from a static parent element likedocument
to the span usingon()
: