0

I have a problem showing console log Textarea value in the javascript. I want to follow the textarea format to show value in the console log.

For example textarea value is:

Title: ABC
Time: 11PM
Place: ShangHai

The console log result should be Title: ABC\r\nTime: 11PM\r\nPlace: ShangHai

But my coding result cannot be get the correct console log result. Below is my sample coding:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea type="text" rows="9" class="form-control" id="content" name="content" value="" title="content"></textarea>

<button type="button" id="updateBtn_5" class="btn btn-sm btn-primary" onclick="show()">Show</button>

<script>
function show() {
  var content = JSON.stringify($("#content").html());
  console.log(content);
}
</script>

My sample coding result just shows me "".

Hope someone can guide me on how to solve the problem. Thanks.

Fatt Sky
  • 114
  • 6

0 Answers0