New to jquery. I already got this running in javascript but am switching to jquery so I can use .each. Is there some special rule preventing me from using JavaScripts .replace inside jQuerys .each?
var jse_sanitized_title = "";
var jse_article_title = "";
var jse_article_titles = $('.jse_article_title');
$.each(jse_article_titles, function(i) {
jse_article_title = jse_article_titles[i].innerHTML;
//error for this says jse_article_titles[i].replace is not a function
jse_sanitized_title = jse_article_titles[i].replace(/ /g,"_");
})
EDIT: The purpose of the replace is to replace spaces with underscores.
Presumably you mean:
If you have not already declared
jse_article_title, put a var here, like:Note that you have to reassign it at the end. Finally, there are no special rules like this. jQuery is just a library.