I’m inserting images into dom with javascript and I would like to pass in the second classname and some other properties of the images while calling the function.
So I have functions containing code this:
function movieCreator(movieName){
'<img class="clip terminator" src="images/terminator.png" onclick="imageControl(this);" alt="terminator" />','
};
function movieCreator(movieName){
'<img class="clip rambo" src="images/rambo.png" onclick="imageControl(this);" alt="rambo" />'
};
There is some other stuff inside those functions too but I’m trying to simplify the question a bit. I would like to pass in the words “terminator” and “rambo” while calling the functions like
movieCreator(terminator);
movieCreator(rambo);
but my head gets really stuck while I try to think where to place the quotes and things like that in order to replace those words correctly from the code.
So my question is this: what would be the correct syntax of replacing the word “terminator” with a dynamical value that is passed in when the function is called?
Call function like
Create function like