CodeIgniter Forums
remove() in jquery not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: remove() in jquery not working (/showthread.php?tid=43806)



remove() in jquery not working - El Forum - 07-24-2011

[eluser]mehwish[/eluser]
Hi can anyone tell me why remove() is not working in the following code
Code:
$("#mydropdown_for_month").change(function(){
  $("#mydropdown_for_day").remove();
   for (var i=1; i<=31; i++)
   {options += '<option>' + i+'</option>';}
   $('#mydropdown_for_day').after().html(options);

I have two select boxes with ids "mydropdown_for_month" and "mydropdown_for_day". The problem is that when I click any month in the first dropdown , second dropdown normally shows all the dates from for loop as i have mentioned but when i again change the month say from feb to april the second dropdown show dates from 1 to 31 twice (may be 1 to 31 for first i slect month and 1 to 31 again for the second time when i select april). so to solve this i put the following statement
Code:
$("#mydropdown_for_day").remove();
so that on every selection from the first dropdown , second dropdown's all previous options get removed but no use.

Please help me where am i making msitake?


remove() in jquery not working - El Forum - 07-24-2011

[eluser]toopay[/eluser]
Its hard to guess without seeing your view structure.