Bug Tracker

Ticket #8469 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

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/

Change History

comment:1 Changed 3 years ago by random.genius

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.

Version 0, edited 3 years ago by random.genius (next)

comment:2 Changed 3 years ago by random.genius

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.

comment:3 Changed 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

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.

Note: See TracTickets for help on using tickets.