Side navigation
#8469 closed bug (invalid)
Opened March 08, 2011 09:21AM UTC
Closed March 08, 2011 02:56PM UTC
nth-child selector problem in certain browsers
Reported by: | random.genius | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.next |
Component: | unfiled | Version: | 1.5.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I posted this on the forum but no replies. I'm having trouble with the selector to get/set data in certain columns. The example should place 'A' in the 3rd column but on the first row it places it in the 4th column. This seems to work fine in IE8 & Firefox 3.6 but doesn't work in Chrome 9 and Safari 5.
$(document).ready(function(){ var originalRow=$('#row1').html(); function newRow(r){ var col=1 var str="" str = '<tr id="row'+r+'">'; str += originalRow; str += '</tr>'; return str; } rows="" for(row=2;row<5;row++){ rows=rows+newRow(row) } $('#editlist tr:last').after(rows); $('#editlist tbody tr td:nth-child(3) input').val("A"); }); <form name="form1" method="post" action=""> <table width="100%" border="0" cellpadding="4" cellspacing="0" id="editlist"> <thead> <tr> <td>Field 1</td> <td>Field 2</td> <td>Field 3</td> <td>Field 4</td> </tr> </thead> <tbody> <tr id="row1"> <td><input type="checkbox" value="checkbox"></td> <td>text</td> <td><input type="text" size="13"></td> <td><input type="text" size="10"></td> </tr> </tbody> </table> </form>
I originally noticed this problem when I was using .each. For example to just console.log the value of a certain column. I would find that the second time I call it, it would display the correct result.
jsFiddle example http://jsfiddle.net/dreaminblue/Lenqt/
Attachments (0)
Change History (3)
Changed March 08, 2011 09:33AM UTC by comment:1
_comment0: | I realise that should be the first row is correct and it's the other rows are incorrect! Only happens because of the dynamically created rows. → 1299578937892335 |
---|
Changed March 08, 2011 10:30AM UTC by comment:2
Well I think I found my problem, simply putting a colon before the input selector fixes it for me although I still think there's an underlying problem still there.
Changed March 08, 2011 02:56PM UTC by comment:3
resolution: | → invalid |
---|---|
status: | new → closed |
You were right in posting on the forum, since this is the bug tracker. Sorry nobody answered but that may mean they either didn't have the answer or didn't understand the question.
As a side note, I noticed that if the second column becomes an input as well it fixes it. I can't see how "tbody tr td:nth-child(3) input" is effected by this, shouldn't it find the nth-child of td regardless of what's contained within it?