There are two new lines in database, but only one new line counted in Javascript
There are two new lines in database, but only one new line counted in Javascript
I really confused with this, I have a value taken from database which has two new lines. But then, I'm using .length in jQuery, and it only counts 1 line.
this is the code I'm using:
let text = $('#signature').text().length;
console.log(text);
It should be '9' (7 + 2 newlines), but the result is '8'
this is the data in the database:
This is the value that I print in the console: 
Thanks for the help
SELECT COUNT(*)
@TimBiegeleisen No, it's only 1 record, what I need to count is the length of the string
– rhog23
Jul 2 at 6:21
Can you add the output of
$('#signature').text() here?– web-nomad
Jul 2 at 6:22
$('#signature').text()
id is for unique identity you should use class in jquery and html.
– Parth Shah
Jul 2 at 6:35
@rhog23 Could you please clearly describe your question. The question description itself causing a bit confusion for readers. The string you specified "Testing" has length 7 but you are saying the exact length is 8. Then your below statement is difficult to digest : "It should be '9' (7 + 2 newlines), but the result is '8' " . Are you considering new lines in the DB as a single character. Going forward, please mention enough description of the Question.
– Satyam
Jul 2 at 9:21
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
It's kind of hard to digest your database information. Does
SELECT COUNT(*)return 9 records, or just 8?– Tim Biegeleisen
Jul 2 at 6:19