简体   繁体   中英

jQuery append function not working in IE8

Why is my jQuery append function not working in IE8

<script type="text/javascript">
function addRows()
{ 
    i=1;
    $("#MyTable").append('<tr><td><input type=checkbox  name=rowchk\<%=i%> value="checkbox" checked="checked" style="display: none;" /></td>'
    +'<td>Cheque / DD no<input type="text" name="cheque_txt1" /></td>'
    +'<td>Cheque/DD Date<input type="text" name="date_txt1" /></td>'
    +'<td>Bank Name <input type="text" name="bank_txt1" /></td>'
    +' <td>Pay Amount   <input type="text" name="amount_txt1" /></td>'
    +'</tr>');
i++;
}</script>

Error shown by IE8

Message: Object expected

You have to be sure that document is ready. Have you tried calling the function from jquery document.ready? http://api.jquery.com/ready/

<script>

    $(function() {

          // Call your functions
          addRows();

    });

</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM