选择日期选择器时如何找到目标。
我试过了
Date: <input type="text" id="datepicker">
$("#datepicker").datepicker({dateFormat: 'yy-mm-dd',onClose:update_date(this)});
function update_date(data)
{
alert($(this).parent().attr('id'));
}小提琴
我期望textbox的结果datepicker id
谢谢
发布于 2014-08-27 05:44:34
尝尝这个,
$("#datepicker").datepicker({dateFormat: 'yy-mm-dd',onClose: function(){update_date(this);}});
function update_date(data)
{
alert($(data).attr("id"));
}检查小提琴
发布于 2014-08-27 05:44:50
尝试以这种方式使用onClose:
$("#datepicker").datepicker({dateFormat: 'yy-mm-dd',onClose: function(dateText, inst){ console.log(inst.id); }}); //this will give 'id' as 'datepicker'小提琴:- http://jsfiddle.net/gahrfdfj/
或者说这个很好:
$(document).ready(function(){
$("#datepicker").datepicker({dateFormat: 'yy-mm-dd',onClose: function () {
update_date(this);
}});
function update_date(data)
{
alert(data.id);
}
})发布于 2014-08-27 05:41:57
你可以这样做:
var myDate = $("#datepicker");
myDate.datepicker({dateFormat: 'yy-mm-dd'});
myDate.change(update_date);
function update_date()
{
alert($(this).attr('id'));
}请参阅下面的JSFiddle
https://stackoverflow.com/questions/25519599
复制相似问题