last day (14 days later) » 

3:17 AM
1
A: How to find the first empty row in an HTML table using Javascript

guest271314 I would like to find the row number of the first row with empty cells You can use :has(), adjacent sibling selector + to match td:empty, that has next element sibling that is td:empty, :first, index(). The index of the first tr element which has a child td element without child nodes would b...

 
@PatrickEvans :$("#myTable tr:not(:has(td:not(:empty))):first").index()
 
@PatrickEvans See updated post
@PranavCBalan You can also use adjacent sibling selector +
 
@guest271314 : in case there is three column , you need to use another +
 
@PranavCBalan "in case there is three column" You could use general sibling selector ~ called on first empty td
 
@guest271314 : that will also skip element, please check that
 
3:17 AM
@PranavCBalan "that will also skip element" Which element would it skip?
 
can you sho a demo with it?
in fiddle
 
"can you sho a demo with it? in fiddle" You commented "that will also skip element, please check that" Can you create jsfiddle to demonstrate?
 
with the same code ..... with an afiitional column
 
Though note, "in case there is three column" does not appear as requirement at original Question
 
I'm not about the question , just about your comment _ You could use general sibling selector ~ called on first empty td_
jsfiddle.net/0sx1sb2b , ~ will not work here
:)
 
3:22 AM
"with the same code ..... with an afiitional column" Yes, jsfiddle returns expected results. What do you mean by "will not work"?
 
third column contains one non empty td
sorry index 3(4th row)
I would like to find the row number of the first row with empty cells , it's fails there
that's all
 
Yes, you are correct. Would need to further adjust selector to check for three consecutive empty elements. Though, again, this was not original Question
 
Yup... :)
 
Perhaps consider adding description of your approach, concerning three consecutive elements case, at your Answer
Note, js at post using + should meet requirement described at original Question
That is, describe why your approach is necessary? Where original Question requirement appears to be two adjacent empty td elements?
 

last day (14 days later) »