如何获取jquery中更改日期选择器的值 [英] How to get the value of date picker on change in jquery
本文介绍了如何获取jquery中更改日期选择器的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要获取日期onchange的值,
I need to get the value of date onchange ,
这里是代码
<div class="input-daterange" data-date-format="dd/mm/yyyy">
<label>Date </label>
<input id="value_date" class="form-control" name="start" type="text" />
</div>
这是我的jquery
Here is my jquery
$('#value_date').change(function() {{
var valuefirstone = document.getElementById('#value_date').value;
alert(valuefirstone);
}
</script>
没有打电话,我只是在变化中创建警报,但它不工作
Onchange the function is not calling, I have just create alert on change but its not working
推荐答案
最好使用 jquery
内置 jquery context
中的函数,另外您的 jQuery更改函数
语法和
it is better to use jquery
built in functions inside a jquery context
. Also your jquery change function
syntax and javascript
code to get the value from date picker is wrong.
将您的jQuery更改功能更改为:
change your jquery change function to:
$(document).ready(function(){
$('#value_date').change(function() {
var valuefirstone = $(this).val();//use jquery built in functions
alert(valuefirstone);
});
});
确保用文档包装更改函数准备好fn
Make sure you wrapped the change function with document ready fn
这篇关于如何获取jquery中更改日期选择器的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文