2009-09-09 99 views
0

我使用jQuery的日期選擇器,請參見下面的代碼如何添加ALIGN =「absMiddle」 jQuery的日期選擇器

$(document).ready(function() 
{   
    $(".txtDate").datepicker({ 
    showOn: 'button', 
    buttonImage: '../images1/calendar.gif', 
    buttonImageOnly: true, 
    dateFormat: 'dd/mm/yy',  
    showOtherMonths: true, 
    showStatus: true, 
    onSelect:function(){} 
    }); 

}); 

和使用日期選擇器後生成的代碼如下:

<td class="gridWidth175"> 
    <input type="text" class="txtDate hasDatepicker" id="ctl00_ContentPlaceHolder2_txtFromSearchDate" name="ctl00$ContentPlaceHolder2$txtFromSearchDate"/><img class="ui-datepicker-trigger" src="../images1/calendar.gif" alt="..." title="..."/> 
    <input type="text" class="txtDate hasDatepicker" id="ctl00_ContentPlaceHolder2_txtToSearchDate" name="ctl00$ContentPlaceHolder2$txtToSearchDate"/><img class="ui-datepicker-trigger" src="../images1/calendar.gif" alt="..." title="..."/>        
</td> 

現在,如果您看到有空白的「alt」和「title」,我想給予alt文本以及我想添加「align ='absMiddle',以便在頁面上呈現之前,我的img標記將如下所示:

<img class="ui-datepicker-trigger" src="../images1/calendar.gif" alt="Select Date" title="Date" align="absMiddle"/> 

請幫忙!

回答

1

你可以初始化日期選擇器後手動添加這些屬性:

$('.ui-datepicker-trigger').attr('alt', 'Select Date').attr('title', 'Date'); 

至於align屬性,我將某處設置在CSS樣式表,而不是JavaScript的。

+0

非常感謝Rayell的幫助! – 2009-09-09 05:56:53