Solved

How to set   using JavaScript

Posted on 2004-10-18
4
2,566 Views
Last Modified: 2009-07-29
Hi

          I wants to add space to the element in my site using javascript. How can i add " " (dynamically) using javascript?

guna.
0
Comment
Question by:b_rajathilagam
4 Comments
 
LVL 12

Accepted Solution

by:
minichicken earned 500 total points
ID: 12345193
Looking for this?

If you want to insert a non-breaking space you can insert it using the
charactor code. Like this:

var nbsp = document.createTextNode( "\u00A0" );            
referenceToWhereYouWantIt.appendChild( nbsp );

source:
http://www.faqts.com/knowledge_base/view.phtml/aid/5887
0
 
LVL 25

Expert Comment

by:devic
ID: 12345300
where do you want add the space? maybe you need just style margin or padding.

<script>
var myElement=getElementById("myDiv");
myElement.style.marginLeft="10px";
myElement.style.marginTop="10px";
myElement.style.marginRight="10px";
myElement.style.marginBottom="10px";

myElement.style.paddingLeft="10px";
myElement.style.paddingTop="10px";
myElement.style.paddingRight="10px";
myElement.style.paddingBottom="10px";

//or short hand
myElement.style.margin="10px 10px 10px 10px";
myElement.style.padding="10px 10px 10px 10px";

</script>
0
 
LVL 7

Expert Comment

by:sukumar_diya
ID: 12345377
Hi rajathilagam,
Check this HTML page .....

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Add Space</TITLE>
<script language=javascript>
      function fnAddSpace()
      {
            var place=document.getElementById("place");
            place.innerHTML="&nbsp;" + place.innerHTML;
      }
</script>
</HEAD>
<BODY>
<Div id=place><Font Color=Red><B>Helooooo There!</b></Font></Div>
<input type=button onclick="fnAddSpace();" Value="Add a Space">
</BODY>
</HTML>


Hope it helps you....
Sukumar
0
 
LVL 18

Expert Comment

by:arantius
ID: 12347947
What does "add space to the element" mean?
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now