You might want to avoid using IDs and use a class instead.
Like <select class="foo"> or use an attribute like <select bindtome="true">
Then $("select.foo"). or $("select[bindtome=true]") will bind to multiple.
Additionally, you dont have to bind the actual code there, you could call a
seperate function.
Lastly, you could use the 'each" if the code you want to bind is different
depending on circumstances.
"Each" allows you to bind the code one at a time and make adjustments.
Check www.jquery.com/api for cut/paste examples. Hope this helps.
Glen
On 3/2/07, dan j <[EMAIL PROTECTED]> wrote:
Apologies if this has been answered elsewhere, but I couldn't find an
answer
by searching.
I suppose this is a newbie question. Is it possible to assign the same
function to multiple elements with different id's with one call?
For example, with the code below, could I assign the onchange handler to
another element with a different id?
$(document).ready(function() {
// apply onchange handler to 'time' field
$("select#time").change(function(){
// send request with amount & date as variables
$.post("guestCheck.php", {time: $(this).val(), date:
$("select#date").val()}, function(xml) {
//assign callback XML to JavaScript variable
var guests = $("guests",xml).text();
alert (guests);
});
});
Thanks for any advice.
--
View this message in context:
http://www.nabble.com/multiple-elements%2C-one-function-tf3332805.html#a9267242
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/