I have an HTML element ("summary-people") which contains the text: "People: 2"
, for example.
I want to just get the number from this. Is there any way I can extract the number as an int from the HTML element? I am very new to JQuery and Javascript and would appreciate any help. However, here's what I've tried already:
function getNumberOfPeople(people) {
var number = $("#summary-people").text();
// the above line returns "People: 2"
var text = number;
var integer = parseInt(text, 10);
return integer;
}
I'm not even sure if what I am trying to do is possible but I feel there must be a way somehow to extract just the number?