-3

So I have a basic table, in which some of the <td> tags consist of a div defined by a class called "chapter-div".

Is there a way I could access only the <td>s which have the "chapter-div" divisions inside of them (USING ONLY THIS TRAIT OF THEM), excluding all of the others tds?

For perception purposes, if we can do this in CSS:

td > .chapter-div

What I'd like to do is something like this:

td < .chapter-div

Thank you in advance!

Harry
  • 80,224
  • 23
  • 168
  • 185
user2182300
  • 13
  • 1
  • 4
  • what have I just read... Your markup and stylesheet is utterly wrong if you want to do this kind of selecting an element. – knitevision Dec 21 '14 at 15:00
  • It's not possible in CSS. Solution: add a class to the td itself if it contains such an element. You could do that using JavaScript, but personally I think this is a server side issue that should be solved when generating the page. – GolezTrol Dec 21 '14 at 15:05
  • What a nice person you seem to be, @knitevision. – user2182300 Dec 21 '14 at 15:23

1 Answers1

0

This can only be achieved with Javascript. If you're using jQuery, its pretty simple:

$('.chapter-div').parent().addClass('chapter-div-parent');

Then you can style your td with the .chapter-div-parent class.

passatgt
  • 3,311
  • 2
  • 34
  • 47
  • Thank you! The reason why I asked this question is because someone asked me so modify his code using only these traits. I'll use your solution. – user2182300 Dec 21 '14 at 15:24