Reputation: 6957
I have hierarhical dropdown which has 3+ steps. Im using very convenient WordPress function which uses
to fake <optgroup>
/ hierarchy. Don't tell me to use <optgroup>
like everybody else, it doesn't work with more than 2 steps in hierarchy.
Strings in HTML
looks something like this:
Colors (21)
Red (7)
Dark (3)
Light (4)
Blue (13)
Dark (5)
Light (8)
Yellow (1)
Light (1)
Which outputs something like this in dropdown:
Colors (21)
Red (7)
Dark (3)
Light (4)
Blue (13)
Dark (5)
Light (8)
Yellow (1)
Light (1)
I need to remove the white space before the word when the item is selected.
Im currently using myString.html.replace( / /g,'' );
but it also removes white space between the word and (count).
How to remove the white space only before the word and not between the word and (count)?
Upvotes: 0
Views: 36
Reputation: 388316
You can use the starts with notation, which will select only
at the beginning of the string
myString.html.replace( /^( )+/,'');
Upvotes: 2