Reputation:
I wanto to insert a space at the start of my string Example:
MySite
MySite (I want this)
I have tried in this mode but nothing
txt=" "+v.text();
Can someone help me? Thanks a lot
Upvotes: 0
Views: 25465
Reputation: 1422
var str2 = " Here goes your string with spaces";
Upvotes: 1
Reputation: 977
There are 2 solutions below :-
1. txt="<pre> </pre>"+v.text();
2. txt="<span style='margin-left:15px'></span>"+v.text();
Upvotes: 0
Reputation: 123367
A solution is to fill the spaces with
entities, but if you have to achieve this effect just for styling/visualization purpose, then wrap that line in a proper tag and use some CSS instead (e.g. text-indent
property)
if you have to indent text inside a select (as I guess reading your previous answer) you may want to wrap your options inside an optgroup
element (and give it some padding)
Upvotes: 5
Reputation: 2671
Try :
txt=" "+v.text();
The other good solution would be to use div with some style set on it.
<div style='margin-left:15px' id='main_text'></div>
You could use jQuery to place txt in the div.
txt= v.text();
$('#main_text').html(txt);
Upvotes: 7