In my jquery i have code for showing some buttons:
if (values[1].length>0 && values[1]!=0)
{
$("input[id="+id.slice(0,-1)+"].to-cart").show();
$("input[id="+id.slice(0,-1)+"].to-cart").val("В корзину");
};
But main trouble that i can have in values: >8, 4<, 3~ etc, but how to split only numbers in my variable?
So my >8, 40<, 3~ i need to do for check, and view it as 8, 40, 3… but i have many symbols, not only ><
I’m not sure if I understand the question correctly. You have strings like
">8"or"<4"and you want to get the digit out of the string? If that is the problem you can use regular expressions:This will return the
8. If you know you’ll deal with numbers with more than one digit your pattern should look like this: