This logs the values of each of 10 textarea elements as expected:
$('.container').each(function() {
var textA = $('textarea', this).val();
console.log(textA)
});
This regex works fine in the console:
"https://hi.com/hey junk nothing https://hi.com/there".match(/https:\/\/hi\.com\/[A-Za-z_]{1,15}/ig);
I get back: ["https://hi.com/hey", "https://hi.com/there"]
But when I try this:
$('.container').each(function() {
var textA = $('textarea', this).val();
var matches = textA.match(/https:\/\/hi\.com\/[A-Za-z_]{1,15}/ig);
console.log(matches)
});
I get Uncaught TypeError: Cannot read property 'match' of undefined
Why undefined? Is it because the Type of what is coming in to match hasn't been declared properly? If so, how should I declare so that it can be 'seen'?
textAto be undefined ?$('textarea', this).val();return something. maybe there is a.containerthat do not contains atextarea.containerwith not texterea in it, returning this error. Here the same problem in a fiddle : jsfiddle.net/jvmmxrb1