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.
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)
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.