我初学jquery和javascript ..请帮助我..我想得到" x"变量存储在HTML div中...
<script>
var x='';
$('#calendar').datepicker({
//altField: '#datepicker_send',
inline: true,
firstDay: 1,
showOtherMonths: true,
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
onSelect: function(dateText) {
x = dateText;
//alert(x);
}
});
<div class="evnt-p">No Events on : <script>document.write (x); </script> </div>
答案 0 :(得分:1)
您需要更新datepicker值的日期,以便
<div class="evnt-p">No Events on : <span id="event-date"></span></div>
然后
$('#calendar').datepicker({
//altField: '#datepicker_send',
inline: true,
firstDay: 1,
showOtherMonths: true,
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
onSelect: function (dateText) {
$('#event-date').text(dateText)
}
});
答案 1 :(得分:1)
<script>
var x='';
$('#calendar').datepicker({
//altField: '#datepicker_send',
inline: true,
firstDay: 1,
showOtherMonths: true,
dayNamesMin: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
onSelect: function(dateText){
x=dateText;
$('.evnt-p span').text(x);
}
});
<div class="evnt-p">No Events on : <span></span> </div>
工作代码