[jQuery] Rename several divs

[jQuery] Rename several divs


Hi
I've got three div elements with id as following: "foo-1", "foo-2" and
"bar-3". And now I want a js function to fetch all divs that have an
id that starts with "foo-" and then replace it with "bar-" following
with the corresponding number.
I've found out how to select all elements whose id starts with "foo-":
div[@id^=foo-]
But I don't know how I can replace the "foo", and still have the
number after -.
Hope you understood my question.