Reputation: 1030
I am using dropdown list to get the selected text value here is my code
var priceValue = $("#ddlprice option:selected").text();
and i am getting value like Basic Cotton Ultra ($20.05)
I just want Basic Cotton Ultra from the value so how can i extract this.
Upvotes: 0
Views: 65
Reputation: 655
just split it before '(' and you will get the output..
var pricevalue = "Basic Cotton Ultra ($20.05)";
pricevalue = pricevalue.split('(')[0].trim();
//output will be "Basic Cotton Ultr
Upvotes: 1
Reputation: 14712
Just use Regular expression to remove all the brackets and tex inside like bellow snippet :
var result = "Basic Cotton Ultra ($20.05)".replace(/ *\([^)]*\) */g, "");
alert(result);
console.log(result)
Upvotes: 2