I have a function and Im trying to change its argument from one file to multiple files that I don't have to define in the code. After mucking around for a little bit I found a way to make it take one unnamed at 开发者_开发百科the time file but not multiple, any help would be greatly appreciated.
function playFlash() { $(""#" & video_id & "_preview"").click() }
Sorry if all of my terms are wrong, I'm kind of self taught in this subject and made up terms as I went.
If what you want is to work with an unspecified number of arguments to a JavaScript function, you can use the arguments
property:
http://www.devguru.com/technologies/ecmascript/quickref/arguments.html
If this is what you are asking: Javascript functions can by default accept multiple parameters(inputs). They are stored in an array called Arguments. You can then loop through that array as many times as there are parameters in the array, and perform some logic on them.
Since it's not completely clear, here's a basic example that demonstrates the principle. Source: http://www.roseindia.net/java/javascript-array/javascript-array-arguments.shtml
function days() {
var items = days.arguments.length
for (i = 0;i < items; i++){
document.write("<li>" + days.arguments[i] + "</li>" );
}
}
days("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
Would Print
- Sunday
- Monday
- Tuesday
- Wednesday
- Thursday
- Friday
- Saturday
精彩评论