Monday 29 August 2016

How to split lines and append in div box using Jquery

Use the below code to have text shown in multiple lines inside the span

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("#btnclick").click(function () {   
    var multiStr = ["Ist Line","IInd Line"];
    for (i=0;i<multiStr.length;i++){  
       var spancr='<p><span>'+multiStr[i]+'</span></p>';
       $("#divbox").append(spancr);
    }
    });
});
</script>
</head>
<body>

<div id="divbox">
 Div Box...
</div>
<button id="btnclick">Click me</button></body>
</html>