This may not be the best way, but this is the first thing that I
thought of.
i = 0;
while ( true ) {
var button = $("#editimage" + i);
if ( button.length ) {
button.click(function() {
loadPopup("Image" + i);
});
}
else
break;
i++;
}
On Jan 16, 7:44 am, Peter <[email protected]> wrote:
> I have a load of buttons with almost similar names but with a number
> identifying them:
> id=editimage1
> id=editimage2
> id=editimage3
> id=editimage4
> etc.
>
> In the onclick event of these buttons I want to do something:
> $("#editimage1").click(function() {
> loadPopup('Image1');
> });
>
> Now I can place this function in my js files as many times as the
> button occurs, but that seem rather inefficient.
> I'd rather have a single function which I can reuse for all buttons,
> something like this pseudocode:
>
> $("#editimage{imgId}").click(function() {
> loadPopup('Image{imgId}');
> });
>
> Is that possible?
>
> Thanks!
--
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en.