admin管理员组文章数量:1435859
I'm using the jquery-ui datepicker. The problem is, the library inserts the calendar icon straight after the input field by default. But my HTML markup is a bit different and I want the calendar icon to appear somewhere else in the DOM, i.e. outside the parent container of the input field.
I even tried to add my own <img/>
manually and added the class ui-datepicker-trigger
, but it doesn't trigger anything.
How can I decide where the icon should appear in the DOM and it has to work?
This is what I want:
<div class="parent">
<input id="datepicker" class="hasDatepicker" type="text" />
</div>
<img class="ui-datepicker-trigger" src="images/calendar.gif" alt="..." title="..." />
Not this (default jquery-ui insertion):
<input id="datepicker" class="hasDatepicker" type="text" />
<img class="ui-datepicker-trigger" src="images/calendar.gif" alt="..." title="..." />
Many thanks
I'm using the jquery-ui datepicker. The problem is, the library inserts the calendar icon straight after the input field by default. But my HTML markup is a bit different and I want the calendar icon to appear somewhere else in the DOM, i.e. outside the parent container of the input field.
I even tried to add my own <img/>
manually and added the class ui-datepicker-trigger
, but it doesn't trigger anything.
How can I decide where the icon should appear in the DOM and it has to work?
This is what I want:
<div class="parent">
<input id="datepicker" class="hasDatepicker" type="text" />
</div>
<img class="ui-datepicker-trigger" src="images/calendar.gif" alt="..." title="..." />
Not this (default jquery-ui insertion):
<input id="datepicker" class="hasDatepicker" type="text" />
<img class="ui-datepicker-trigger" src="images/calendar.gif" alt="..." title="..." />
Many thanks
Share Improve this question asked Apr 25, 2013 at 10:15 ShaozShaoz 10.7k26 gold badges76 silver badges100 bronze badges 3-
1
@Kasyx, I don't want to do that because, that's what causes the insertion straight after
<input/>
. That's what I asked in the question, how to cancel that default behaviour... – Shaoz Commented Apr 25, 2013 at 10:19 - Yes sorry, my fault. Now i understand your problem. – Kasyx Commented Apr 25, 2013 at 10:22
- No problem, it's cool. – Shaoz Commented Apr 25, 2013 at 10:23
2 Answers
Reset to default 2Try to manually add trigger which will show datepicker on image click:
$("#datepickerImage").click(function() {
$("#datepicker").datepicker( "show" );;
});
try this
$(selector).datepicker({showOn: 'button', buttonImage: 'img/cal.gif',
buttonImageOnly: true, buttonText: 'Open calendar'});
SEE HERE
本文标签: javascriptJquery datepicker calendar icon positioningStack Overflow
版权声明:本文标题:javascript - Jquery datepicker calendar icon positioning - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745656261a2668726.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论