JQuery & # 8594; selectors all TDs in a specific table

I'm still learning jQuery and the selector bit is incredibly useful, but I still don't understand it completely.

I have a table with id = table1 and I want to select all td in this table.
(indeed, I want to wrap the text inside each td with an overflow div: hidden so that I can make the cell heights be uniform.)

What is the appropriate syntax for jQuery (javaScript?) Selector?

Any links to amazing selection guides are also welcome.

+3
source share
4 answers

The following should do the trick

$('#table1 td').wrapInner('<div class="no-overflow"></div>');

and add the CSS rule to the stylesheet

.no-overflow{
      overflow:hidden;
      /*and whatever other css properties here*/
 }

+5

:

$("#table1 td") 

jQuery CSS3, : http://api.jquery.com/category/selectors/

+3
$("#table1").find("td");
+1
source
$("#table1 td").each(function() {
  var text = $(this).html();
  var div = $("<div class=hiddenOverflow></div>");
  div.html(text);
  $(this).html(div);
});
0
source

Source: https://habr.com/ru/post/1773318/


All Articles