ahlt wrote:
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-":
[EMAIL PROTECTED]
But I don't know how I can replace the "foo", and still have the
number after -.

Hope you understood my question.

Try this:

$('[EMAIL PROTECTED]"foo-"]').attr('id', function() {
    return this.id.replace('foo', 'bar');
});


--Klaus

Reply via email to