How can I change the "20" into the variable "words"?
var words = 125;
$(".px-text-module-<?php echo $id; ?>").html($(".px-text-module").html().replace(/([a-zA-Z]+[.,]? ){20}/, function(x) {
return '<div class="read-more-wrapper"><p class="read-more-content">' + x + '<span class="read-more-dots">...<br></span></p></div><p>';
}));
}
This should be the code but it does not work:
var words = 125;
$(".px-text-module-<?php echo $id; ?>").html($(".px-text-module").html().replace(/([a-zA-Z]+[.,]? ){words}/, function(x) {
return '<div class="read-more-wrapper"><p class="read-more-content">' + x + '<span class="read-more-dots">...<br></span></p></div><p>';
}));
}