0
<strong class="prc">
  <dd>
    <del>42,680$</del>
  </dd>
  38,412$
</strong>

I want to select 38,412. But I don't know how to select only 38,412 without 42,680$.

Now I got the result of 4,268,038,412 so it looks like a very huge number.

sandyJoshi
  • 733
  • 9
  • 20
Bora Lee
  • 23
  • 4
  • `DD` in `STRONG` is nonsense. The most logic way is to add any markup around new price. – pavel Dec 12 '17 at 08:50
  • Possible duplicate of [Using .text() to retrieve only text not nested in child tags](https://stackoverflow.com/questions/3442394/using-text-to-retrieve-only-text-not-nested-in-child-tags) – Jack jdeoel Dec 12 '17 at 09:55

4 Answers4

0

I know the answer to only jquery

$('strong').not('dd')

But I don't know any css selector.

for CSS :-

How to select a text (without tag) in a div using CSS selector?

0

It is not possible to style text nodes by themselves, however you may be able to solve your problem with overrides.

If you style your strong element the way you would like the text node styled, you can override it with the dd element, like so:

strong
{
    color: red;
}

strong dd
{
    color: blue;
    display: inline-block;
    margin-right: 1em;
}
Jake
  • 4,014
  • 8
  • 36
  • 54
0

Here you go with a solution

var dd = $('dd').text();
var totalText = $('.prc').text();

console.log(totalText.replace(dd, ''));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<strong class="prc">
  <dd id="dd">
    <del>42,680$</del>
  </dd>
  38,412$
</strong>

First grab the text from strong & dd, then replace the dd text from the strong text.

This is a work around, may be a solution what you are looking for.

Hope this will help you.

Shiladitya
  • 12,003
  • 15
  • 25
  • 38
0

Here you go : We have a :not selector in CSS, so you can use it :

strong:not('dd') {

}

Structure :

Element:not(selector) { css declarations; }

Velkov
  • 16
  • 4