+1  A: 

You can find an example of getting inner text from a <p> tag here. Same thing with a <span>.

To set it you just need to assign the InnerText property.

If your javascript snippet is out of scope (in a function etc) use the GetElementById method of the document global object to retrieve your <p> or <span> or whatever - in fact you can do this with any element provided you assign an id to the element.

JohnIdol
A: 

JohnIdol's answer will work in all modern browsers except Firefox. See here for a browser compatibility chart on innerText. As the link also shows, you can use textContent to get the same thing in FF.

The suggestion to use getElementById is an excellent one, but it's good to note that you can still access the text of an element if it doesn't have an id attached to it, which is frequently the case with <p> and <span> tags. For example if you know the 4th <p> tag has the text you want you can do the following:

var p = document.getElementsByTagName('p')[3];
var text = p.innerText || p.textContent;
Bryan