Skip to content

Instantly share code, notes, and snippets.

@daylik
Last active April 11, 2017 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daylik/ef1b8dd5704c6db65a8e9e01e9729c1e to your computer and use it in GitHub Desktop.
Save daylik/ef1b8dd5704c6db65a8e9e01e9729c1e to your computer and use it in GitHub Desktop.
function each_table_td( selector, td_num, find_regexp, replace_regexp, replace_mask, _e){
_e = {};
$( selector ).each(function(index_1, el) {
_e.num = 0;
$(el).find('tr td').each(function(index_2, el_2) {
_e.num++;
if ( (_e.num % td_num) === 0) {
_e.td = $(this).html();
//$(this).addClass('this_test');
if (find_regexp.test(_e.td)){
_e.td = _e.td.replace(replace_regexp, replace_mask);
$(this).html(_e.td);
}
}
});
});
}
setTimeout(function(){
each_table_td( '.new_table table', 3, /(от)?[\s-]*[\d]+/, /([\d]+[-\s\d]*)/, '<span class="num">$1</span>');
}, 500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment