jquery date picker show only month with .css issue
I want to change datepicker to select month only. I can change with change css property like this
<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"&开发者_Python百科gt;</script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
</head>
<body style="font-size:62.5%;">
<input class="todaydate" type="text" name="todaydate" />
<p>test paragraph</p>
<script>
$('.todaydate').datepicker();
</script>
<style>
.ui-datepicker-calendar {
display: none;
}
</style>
</body>
</html>
It works, but when I want to change css with jquery like this, it not work
<script>
$('.todaydate').datepicker();
$('.ui-datepicker-calendar').css({display:'none'})
</script>
Help me please
1) is there javascript error in your console? 2) if i'm not wrong this $('.ui-datepicker-calendar').css({display:'none'}) works for html elements. http://api.jquery.com/css/ http://api.jquery.com/category/selectors/ 3) try to put your script below whatever you want to select as html rendering starts from top to bottom. ......
.....It's because you need a document.ready. Do this:
<script>
$(document).ready(function(){
$('.todaydate').datepicker();
$('.ui-datepicker-calendar').css({display:'none'})
});
</script>
Hope this helps. Cheers
supposing you want to hide the calendar using jquery and not css for some weird reason of yours. you can try this:
$('.todaydate').datepicker();
$('.todaydate').click(function(){
$('.ui-datepicker-calendar').css('display','none');
});
check it out live here... http://jsfiddle.net/FRQ2D/
it will hide the calendar with no problem, but I'm not sure how you gonna select just the month xD (maybe with some blur() magic :P).
there's no event call to trigger the .css() so your coding there is bad...
精彩评论