How to add line breaks to an HTML textarea?
Hi Guys,
In this example,I will learn you how to add line breaks to an html textarea.you can easy and simply add line breaks to an HTML textarea.
split(): is a predefined JavaScript function that splits a string into an array using a parameter.
join(): is a predefined JavaScript function that joins an array to convert it into a string using provided parameters.
Example :
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function divide() {
var txt;
txt = document.getElementById('a').value;
var text = txt.split(".");
var str = text.join('.</br>');
document.write(str);
}
</script>
<title></title>
</head>
<body>
<form>
ENTER TEXT:
<br>
<textarea rows="20"
cols="40"
name="txt"
id="a">
</textarea>
<br>
<br>
<input type="submit"
name="submit"
value="submit"
onclick="divide()" />
</form>
</body>
</html>
It will help you...
- How to Use the groupmod Command in Linux?
- How to Restrict Access to a Folder with htaccess?
- How to Zip UnZip Files And Directories In Linux using Command Line?
- Laravel 8 Refresh DataTable Without Reloading Page
- How to Model Disable Primary Key & Auto Increment Tutorial?
- How to Remove WordPress Version Number?
- How to Count Total Number of Bits in Number?
- Flutter Route and Navigation Example