I think you can't use the html tags in this manner for this you have to specify and ID for each tag and then access in the jQuery function.
<textarea id="gps" name="gps"></textarea>
<button id="btn">Click</button>
$('#btn').click(function(){
var arrayOfLines = $('#gps').val().split('\n');
$.each(arrayOfLines, function(index, item) {
$this = $(this);
console.log($this);
});
});
Inside .each loop line id 'item' object, not 'this'.
<textarea id="gps" name="gps"></textarea>
<button id="btn">Click</button>
$('#btn').click(function(){
var arrayOfLines = $('#gps').val().split('\n');
$.each(arrayOfLines, function(index, item) {
console.log('here is line:', item);
});
});
You are placing a string into a jQuery object. Just use the item
instead:
$('button').click(function(){
var arrayOfLines = $('#gps').val().split('\n');
$.each(arrayOfLines, function(index, item) {
console.log(item);
});
});
You're not dealing with "this" properly. Try the following:
$('button').click(function(){
var arrayOfLines = $('#gps').val().split('\n');
$.each(arrayOfLines, function(index, item) {
console.log(this);
});
});
Note that the "this" variable in the inner function starts with the newline, I believe. But this should get you on the right track.