-2
我在清除html表單輸入時遇到了問題。 這是我的情況:使用javascript清除兩個輸入
<input id="filefield" type="file" name="fileupload"/>
<textarea id="textareafield" name="textupload"></textarea>
<script>
('#textareafield').change(function() {
value1 = $(this).val();
if (value1 != '') $('#filefield').val('');
});
('#filefield').change(function() {
value2 = $(this).val();
if (value2 != '') $('#textareafield').val('');
});
</script>
如果#filefield使用刪除#textareafield的內容,如果#textareafield用於刪除#filefield內容。我需要一個與JavaScript或jQuery的解決方案。謝謝。
'(...)'只是羣體的表現。在連接變更處理程序的代碼上,您可能需要'$(...)',它調用由'$'標識符引用的jQuery函數,就像稍後查找字段以清除其值時一樣。 –
在Web開發中,要做的關鍵事情之一是在Web控制檯中查看。在這種情況下,它會顯示錯誤'Uncaught TypeError:「#textareafield」.change不是一個函數或類似的,指出問題... –