jQuery Multiple ID selectors
Here's a snippet of the start of my code:
var myUpload = $("#upload_link").upload({bla bla bla
Basically what I'm trying to do is make the same call with a few different ID's...
I would have assumed this would work but it doesn't:
var myUpload = $("#upload_link,#upload_link2,#upload_link3").upload({
Any ideas?
Solution 1:
Try this:
$("#upload_link,#upload_link2,#upload_link3").each(function(){
$(this).upload({
//whateveryouwant
});
});
Solution 2:
If you give each of these instances a class you can use
$('.yourClass').upload()
Solution 3:
You can use multiple id
's the way you wrote:
$('#upload_link, #upload_link2, #upload_link3')
However, that doesn't mean that those ids exist within the DOM when you've executed your code. It also doesn't mean that upload
is a legitimate function. It also doesn't mean that upload
has been built in a way that allows for multiple elements in a selection.
upload
is a custom jQuery plugin, so you'll have to show what's going on with upload
for us to be able to help you.