在電腦上運行良好。在計算機上,輸入單詞并按空格鍵后,單詞會被包裹在一個框中,您可以選擇將其刪除。在手機上,按空格鍵后什么也不會發生。它也不限制手機上的 5 個單詞。工作 jsfiddle:http://jsfiddle.net/1hco43vr/ $('#box a').on('click', function() { $(this).parent().parent().remove(); console.log('remove disabled'); if ($('#box ul li').length <= 5) { $('#type').prop('disabled', false); } });}$('#type').keypress(function(e) { if (e.which == 32) { //change to 32 for spacebar instead of enter var tx = $(this).val(); if ($('#box ul li').length > 5) { $(this).val(''); console.log('add disabled'); $('#type').prop('disabled', 'disabled'); } else { if (tx) { $(this).val('').parent().before('<li><span>' + tx + '<a href="javascript:void(0);">x</a></span></li>'); closer(); } } }});
添加/刪除文本區域中的關鍵字不適用于手機(jquery)
HUX布斯
2023-11-12 15:32:13