2

I am using jquery bootpag to display pagination on a page

<div class="textgray showing"></div>

How should I tell jQuery to select this div? I tried the following without but neither of these attempts work

$(".textgray .showing").html("some text");

$(".textgray showing").html("some text");

P.S I am a beginner in frontend so bear with me

1
  • $(".textgray.showing")
    – haim770
    Commented Feb 7, 2017 at 10:05

2 Answers 2

3

The space means the second part is inside the first one (it's called the descendant combinator). Remove it:

$(".textgray.showing").html("some text");
4
  • this should not be closed as typo?
    – mplungjan
    Commented Feb 7, 2017 at 10:12
  • Typo ? No, really not. It's probably a duplicate though. Find it and I'll close the question. Commented Feb 7, 2017 at 10:13
  • When I said typo I mean the "typo off topic" "cannot be reproduced once you have fixed the space" kind of close
    – mplungjan
    Commented Feb 7, 2017 at 10:14
  • 1
    Duplicate: stackoverflow.com/questions/1041344/…
    – mplungjan
    Commented Feb 7, 2017 at 10:14
0

You don't need to put that extra space in between selector. space in selector looks for descendant elements:

$(".textgray.showing").html("some text");

Not the answer you're looking for? Browse other questions tagged or ask your own question.