Home >Web Front-end >JS Tutorial >Example of replacing line breaks in text fields_jquery

Example of replacing line breaks in text fields_jquery

WBOY
WBOYOriginal
2016-05-16 16:57:171277browse

Note: The code passed the test in the actual project. I have omitted some unimportant parts. You can focus on the color-coded parts

Foreplay:

Question: Why do you do this? ?

Answer: There is a project in the project that saves the entered text field text into the database. 'When viewing' obtains the corresponding data from the database and displays it in the text field. During the development, I found that the newline character is obtained using jquery's val() or text() without processing it. There is no newline character in the saved database. Naturally, there is no newline character when it is taken out and displayed! As a result, I wrote the following article... It's a bit long-winded!

Copy code The code is as follows:

<%@ page contentType="text/html; charset=UTF-8" %>





Interview plan< ;/font>




Solution


< div>
Remarks:








< /div>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn