2

I'm trying to disect the price from a string that is returned part as a variable

price_html: "<span class="price"><span class="amount">£2,196.10</span></span>"

Do you know of a jquery function that could disect this?

Thanks in advance.

1 Answer 1

7

Make a jQuery object and use class selector to get the span with class amount.

Live demo

price_html = $('<span class="price"><span class="amount">£2,196.10</span></span>');
price_html.find(".amount").text()

or with single statement

Live Demo

txt = $('<span class="price"><span class="amount">£2,196.10</span></span>')
        .find(".amount").text()
Sign up to request clarification or add additional context in comments.

1 Comment

or just $(price_html).find(".amount").text(); assuming price_html already exists

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.