Ok, I’m still learning the basics of JS, and I’m stuck in passing parameters via a function.
Why is this script not showing up the number 31 in the test div ?
If I do alert(content); or alert(place); it alerts the right stuff, so it passes the value correctly.
Perhaps the problem is by getting the element by ID. I already tried with different types of ‘’“”, without '", with + with escape things\, but I obviously have no clue what the right approach would be for this.
How do you mean? To put the same function in a new function?
Like this:
function dothisfirst(){
function doit(content,place){
document.getElementById("place").innerHTML = content;
}
doit(31,'test');
}
dothisfirst; // or dothisfirst();
// both not working :s
Get familiar with javascript before launching into jquery itself.
Matt is right you need to call the doit function after the page has loaded otherwise there will not necessarily be the element you are trying to update.
Your function has an argument place but in the getElementById function you have used “place” (a string). Losing the quotes gives you the argument.