I'm learning javascript. My first idea has led to a problem. I'm trying to set up strings to load at random intervals on different parts of the page, but I don't know the right function to use with setTimeout(). I hear "don't use document.write" and "probably don't use innerHTML", but are other functions outside of javascript? Please help.
tefflox
2
Junior Poster
Recommended Answers
Jump to PostsetTimeout() can also take a function as the first parameter.
Using an anonymous function you can rewrite your JS code as:
// example of using a JS closure to persist a lexical environment/scope function addTextNode() { var newtext = document.createTextNode(" Some text added dynamically. "); var …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.