var status = '.status-0' console.log(status.substr(2,2)); //first param by begin, second by cut length, got 'ta' console.log($(this).attr('data-filter').substring(2,4)); // first param by begin index, second by sub index string. got 'ta' also .