How to apply CSS only to numbers in paragraph? (without <span>)

css, html, jquery

Solution

You can't do this with only CSS. Since you also marked your question with a jQuery tag, you can however do it this way:

$('p').html(function(index, value) {
    return value.replace(/(\d+)/g, '<span>$1</span>');
});

jsFiddle example

Problem

How to apply CSS only to numbers in paragraphs without wrapping numbers in `span`s? ``` <p>Text and numbers: 123</p> <p>123 and text</p> ``` Are there any selectors? In jQuery, maybe. Or somehow parse it using javascript... Expected result:

Original source