Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 获取全部<;选项>;下拉列表中的值_Javascript_Jquery - Fatal编程技术网

Javascript 获取全部<;选项>;下拉列表中的值

Javascript 获取全部<;选项>;下拉列表中的值,javascript,jquery,Javascript,Jquery,如何获取下拉列表的所有选项值?我可以根据它们的价值来隐藏它们吗? 例如,我有12个月的下拉列表,现在是2012年10月11日,我想隐藏过去的所有月份,只显示10月3日、11月和12月 下面是我如何尝试da的,你能告诉我,我如何在该循环中获得选项值,因为this.val()不返回它吗 var currentTime = new Date(); var month = currentTime.getMonth(); var year = currentTime.getFullYear(); if (

如何获取下拉列表的所有选项值?我可以根据它们的价值来隐藏它们吗? 例如,我有12个月的下拉列表,现在是2012年10月11日,我想隐藏过去的所有月份,只显示10月3日、11月和12月

下面是我如何尝试da的,你能告诉我,我如何在该循环中获得选项值,因为
this.val()
不返回它吗

var currentTime = new Date();
var month = currentTime.getMonth();
var year = currentTime.getFullYear();
if (year == $('#yearSelected', '#BookingCalendar').val()){
  $('#monthSelected option', '#BookingCalendar').each(
    function (){
      if(this.val() < month) this.hide();
    }
  );     
}
var currentTime=新日期();
var month=currentTime.getMonth();
var year=currentTime.getFullYear();
if(year=$(“#yearSelected”,“#BookingCalendar”).val(){
$(“#月选择选项”,“#预订日历”)。每个(
函数(){
如果(this.val()
检查以下行:

if (this.value < month)   // 'this' is DOM object
    $(this).hide();       // '$(this)' is jQuery object
if(this.value
请同时提供HTML代码。请选择
this.value
$(this.val()