Developer
Developer

Reputation: 8636

Why i am getting multiple images while using Function() in jquery

I use the following Jquery for calendar http://keith-wood.name/datepick.html

My source is as follow

<script type="text/javascript">
$(function()
{
$('#ctl00_ContentPlaceHolder1_textbox1').datepick({showOnFocus: false, showTrigger: '#calImg'});
});
</script>

<asp:TextBox ID="textbox1" runat="Server">
</asp:TextBox>
<img src="calendar.gif" alt="Popup" id="calImg" class="trigger" />

But i am getting multiple images when i see on my browser why this is happening

Link http://i53.tinypic.com/2v0ykd1.png

Upvotes: 0

Views: 116

Answers (2)

Felix Kling
Felix Kling

Reputation: 816790

I don't know how this plugin works internally, but you can see in the example ( http://keith-wood.name/datepick.html -> Invocation -> From image only) that they hide the original image:

<div style="display: none;"> 
    <img id="calImg" src="img/calendar.gif" alt="Popup" class="trigger"> 
</div>

Upvotes: 4

Ole Melhus
Ole Melhus

Reputation: 1929

For some reason the datepick-plugin clones the image. Possible workaround is to just remove the image after loading the datepicker.

<script type="text/javascript">
$(function()
{
$('#ctl00_ContentPlaceHolder1_textbox1').datepick({showOnFocus: false, showTrigger: '#calImg'});
$("#calImg").remove();
});
</script>

Upvotes: 3

Related Questions