這是我的PHP文件中的文本輸入:按鈕,在JS
<input style="text-align: center; max-width: 500px; margin-top: 0px;" type="text" placeholder="Paste your links here separated by a space" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Paste your links here separated by a space'" name='links' id='links' />
<!--lilbanner-->
<BR>
<button class="button alt" id="submit" type="submit">
<?php printf($obj->lang['sbdown']); ?>
</button>
我想要的按鈕與文字輸入是空被禁用,當用戶鍵入文本並刪除它,它會再次清空,意味着按鈕將被禁用。我有以下的代碼,因爲我從我的其他網站想它的工作原理完全,但出於某種原因,它不工作(空文本輸入=鍵..)
<script type="text/javascript">
$(document).ready(function() {
$('.submit').prop('disabled', true);
$('#link').change(function() {
$('.submit').prop('disabled', this.value == "" ? true : false);
})
});
</script>
你能幫助我嗎?提前致謝!
我沒有任何東西代替我知道,但它仍然不工作 –
最簡單的發現可能是解決辦法:您輸入的ID是'links'而比你用於更改事件處理程序的鏈接 – devnull69
Aaaaand:你的按鈕的ID有'submit'而不是'submit'類,你在更改禁用屬性時使用 – devnull69