在图标点击上显示javascript datepicker

时间:2018-04-26 10:27:57

标签: javascript asp.net

当我点击textbox时它正在工作,但我也希望它在icon click上。

有人可以帮帮我吗?

我的源代码是: -

<div class="form-group col-lg-6">
    <div class='input-group date'>
        <asp:TextBox ID="txtfirstDeliverableDt" runat="server" Text="--please Select date--" CssClass="form-control deliverableTextbox date-picker" ></asp:TextBox>
        <span class="input-group-addon" id="datetimepicker1">
            <span class="glyphicon glyphicon-calendar"></span>
        </span>
    </div>
</div>

1 个答案:

答案 0 :(得分:0)

这将是您的java脚本代码: -

$('.open-datetimepicker').click(function(event){
event.preventDefault();
$('#datetimepicker').click();
 });

您的HTML代码如下: -

<div class="input-group">
<input type="text" id="datetimepicker" class="form-control" name="date">
<label class="input-group-addon btn" for="date">
   <span class="fa fa-calendar open-datetimepicker"></span>
</label>