點擊時將跨度轉換爲輸入,當點擊它後再次變爲跨度。但它只轉換一次,然後不再發生點擊後將跨度轉換爲輸入
這是代碼。
$(function() {
$(document).on('click', 'span.loadNum', function() {
var input = $('<input />', {
'type': 'text',
'name': 'unique',
'value': $(this).html()
});
$(this).parent().append(input);
$(this).remove();
input.focus();
});
$(document).on('blur', 'input', function() {
$(this).parent().append($('<span />').html($(this).val()));
$(this).remove();
});
});
,並跨越
<span class="loadNum">Hasha</span>
<span class="loadNum">dbhfb</span>
而且誰能告訴如何實現這一點,當我按下轉換的輸入標籤輸入它應該提交一個Ajax調用。
http://jsfiddle.net/hW3vk/114/ – Alexis