我有這樣的代碼生成輸入字段值從選擇日期
這樣的:http://jsfiddle.net/fauzi/ByTtp/
所以我要生成的輸入字段值birhtday選項被選中。我做JavaScript,但困惑生成月份和年份。
$(document).ready(function() {
$("#pelajar_tglahir_3i option").filter(function() {
return $(this).val() == $("#pelajar_code").val();
}).attr('selected', true);
$("#pelajar_tglahir_3i").live("change", function() {
$("#pelajar_code").val($(this).find("option:selected").attr("value"));
});
});
例當選擇生日是1 March 1990
和輸入字段的值是1March1990
..
作爲一個方面說明:你真的不應該是你sing.live()這是一個糟糕的函數,甚至jQuery團隊建議在舊版本中.on無法使用.delegate over .live – rlemon 2013-03-17 18:18:03