2011-07-08 42 views
0

我JavaScript來創建元素輸入文本框來存儲jQuery的日期選擇器,但它不工作:(jQuery的日期選取器事件

jQuery(document).ready(function($) { 
     $("#pohdddt").datepicker({showOtherMonths: true,selectOtherMonths: true,dateFormat: 'dd.mm.yy',showOn: 'button',buttonImage: "<?php echo base_url()?>icons/cal.gif", buttonImageOnly: true, showAnim: 'slideDown', duration: 'fast'}); 
}); 


var cell = document.createElement("td"); 
    var theInput = document.createElement('input'); 
    var img = document.createElement('img'); 
    img.setAttribute('alt', 'select date '); 
      img.setAttribute('class', 'ui-datepicker-trigger'); 
      img.setAttribute('src',base_url_no_index+'icons/cal.gif'); 

      theInput.setAttribute('id', 'pohdddt'+i); 
      theInput.setAttribute('name', 'pohdddt'); 
      theInput.setAttribute('value', '<?php echo date('d.m.Y'); ?>'); 
      theInput.setAttribute('size', '10'); 
      theInput.setAttribute('class','hasDatepicker'); 

      cell.appendChild(theInput); 
      cell.appendChild(img); 
      row.appendChild(cell); 

如何調用的jQuery事件的onclick這個的Elemen創建時? 如果是的話,我會創造VAR AHREF =使用document.createElement( 'A');?

任何建議

由於之前
Rizq

+1

爲什麼不使用jQuery的一切? – alex

+0

滿足要求 – MRizq

+0

有什麼要求?你可以使用庫,但只有30%的代碼? – alex

回答

0
$('#target').click(function() { 
    alert('Handler for .click() called.'); 
}); 

HTML代碼

<div id="other"> 
    Trigger the handler 
</div> 

完整信息經過http://api.jquery.com/click/