-1

I have created the variable

$divquallist like this...

let $divquallist = $("div.quallist");

but I can't figure our how to access the css property of all trs of the variable.

When I reference the element with jQuery , I can do this

$("div.quallist tr").css ("background","");

and it works the way I want it to.

But I'm at want to do the same thing using my variable.

$divquallist tr.css but I cant seem to get the syntax right.

Thanks

Dave Davis
  • 574
  • 1
  • 4
  • 14
  • 1
    When you say "access all the trs", what exactly are you trying to do? Do you want an array of the values? Are you trying to change them all? What exactly is the end goal? – Taplar May 17 '18 at 20:36
  • jquery has a `.find` method. it can be used to... *find* elements that are descendants of an existing collection. ( `$divquallist` is a collection ) – Kevin B May 17 '18 at 20:46

1 Answers1

0

You can get all of the tr backgrounds (or any CSS property) via something like

$("div.quallist tr").map(function(idx, el) { return $(el).css("background"); })

This will return an array of values, one for each tr object.

Daniel
  • 3,312
  • 1
  • 14
  • 31