Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  7] [ 1]  / answers: 1 / hits: 17150  / 9 Years ago, wed, august 26, 2015, 12:00:00

I am using http://eonasdan.github.io/bootstrap-datetimepicker/ for calendar. Now I want to pick the selected date by the user. I am stuck with this calendar. Please help me to get the current selected date by the user I have used js to get the value.


On each date there is a class named "day". Now I wanted to get the value of the attribute "data-day" which have the value of the date as follows:


$(".day").click(function(){
var clicked = $(this).attr('id');
alert(clicked);
});

It returns the attribute's value only one time it's not recognizing the second click.


Please help me with js or this eonasdan plugin.


More From » jquery

 Answers
-5

HTML



<br/>
<!-- padding for jsfiddle -->
<div class=row>
<div class=col-md-4 col-xs-6>
<input type=text class=form-control id=datetimepicker2 />
<br>
<input type=button class=btn btn-success id=getDate value=Get Date />
</div>
<span id=SelectedDate></span>
</div>


JS



$('#datetimepicker2').datetimepicker();

$('#getDate').click(function () {
console.log($('#datetimepicker2').data('date'))
$('#SelectedDate').text($('#datetimepicker2').data('date'))
})


DEMO

Get Only Date Part


[#65286] Monday, August 24, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alora

Total Points: 284
Total Questions: 99
Total Answers: 92

Location: Singapore
Member since Sat, Jul 25, 2020
4 Years ago
;