Nat*_*son 35
一种方法:
if ($('#myselect option').length == 0) {
$('#myselect').hide();
}
Run Code Online (Sandbox Code Playgroud)
var $select = $('input:select option');
if(!$select.length )
$select.attr('disabled', true);
Run Code Online (Sandbox Code Playgroud)
要么:
$('select:not(:has(option))').attr('disabled', true);
Run Code Online (Sandbox Code Playgroud)
另一种方法是简单地使用 jQuery has函数
if ($('#myselect').has('option').length == 0)
{
// Hide and disable select input here
}
Run Code Online (Sandbox Code Playgroud)
有关 jQuery has函数的信息,请参见:https : //api.jquery.com/has/
归档时间: |
|
查看次数: |
26047 次 |
最近记录: |