lundi 2 mars 2015

Remove string and everything after for each element containing certain string

I have an online store with menu items which need a certain part of their name cut off as its only for my reference.


The part of the string I want to cut is "-123-" and everything after. e.g. "fender-123-guitar" would become "fender"


There are multiple instances of menu items with "-123-" in it so I need to do it for all automatically (not one by one.)


The strings can be selected like so: $( 'li.menu-item > a' ).text()


Thanks!


Aucun commentaire:

Enregistrer un commentaire