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>
<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>
No comments:
Post a Comment