[jQuery] using tabIndex

[jQuery] using tabIndex


I have some fields that may be generated on the fly via DOM, and want
to set the tab index. This isn't working for me:
$("#elem2").attr("tabindex", $("#elem1").attr("tabindex") + 1);
What would the correct syntax be to make the tabindex of elem2 to be
that of elem1 + 1?