0

js code :

...

let wr = $('div[class="topstory-content-wrapper last"]');
    console.log(wr.html());

...


error: throw new SyntaxError("Malformed attribute selector: " + selector); ^

SyntaxError: Malformed attribute selector: class = topstory-content-wrapper last

khashayar
  • 58
  • 5
shauna vayne
  • 159
  • 2
  • 12
  • 2
    Your selector is malformed. The opening `[` doesn't have a closing `]`. There's spaces all over the place, which makes it unclear. – evolutionxbox Jan 20 '20 at 10:15
  • You're opening a `[` but not closing it. – Jeremy Thille Jan 20 '20 at 10:16
  • Does this answer your question? [What are the rules around whitespace in attribute selectors?](https://stackoverflow.com/questions/5930898/what-are-the-rules-around-whitespace-in-attribute-selectors) – evolutionxbox Jan 20 '20 at 10:18

1 Answers1

0

Try to write your selector in the next way:

const wr = $('div.topstory-content-wrapper.last');
Pasha
  • 621
  • 8
  • 21
  • 1
    We can't guarantee that the spaces the OP has aren't needed. Remember `div .topstory-content-wrapper` is _not the same_ as `div.topstory-content-wrapper.last` – evolutionxbox Jan 20 '20 at 10:30
  • Yes, agree. Author can try both variants, depends on his needs. 'div' with class, or element with class inside 'div'. – Pasha Jan 20 '20 at 10:33