Aucun problème avec IE sur ce code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Add row</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<button id="addRow">Ajouter une ligne</button>
<table>
<tr id="row0">
<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td>
</tr>
<tr id="row1">
<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td>
</tr>
<tr id="row2">
<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td>
</tr>
<tr id="row3">
<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td>
</tr>
<tr id="row4">
<td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td>
</tr>
</table>
<script>
$('table').on('click', 'tr', function(){
alert(this.id);
});
$('#addRow').on('click', function(){
var lastRow = $('tr:last');
var row = lastRow.clone(false);
var nb = lastRow.attr('id').replace(/\D/g, '');
row.attr('id', 'row' + ++nb);
console.log(lastRow.attr('id'), row.attr('id'));
$('table').append(row);
});
</script>
</body>
</html> |
var nbLines = $('#rfqItems tr').length-2;
Pourquoi -2 ?
Partager