I'm creating an online shop, with specific links to products *e.g.* (<http://example.com/products/phones/nexus-5>).

I'm using the following code,

```
var get_product_availability_classname = $("[class$='_availability']").attr('class');

```

which selects *(creates a variable with the value of)* the element that has a class ending in "\_availability".

Every product page has a different piece of text just before the `_availability`, like `GOOGLENEXUS5_availability`, `SAMSUNG4KTV_availability`, `whatever_availability`...

**What I have to do** now is to essentially remove the criteria I used to get that whole class name (*i.e.* `class$='_availability'`); using the example above it'd be trimmed from `SAMSUNG4KTV_availability` to `SAMSUNG4KTV`.

Possible solutions
------------------

I haven't figured how to, but we could use JavaScript's substring() or substr().