On Apr 19, 8:38 pm, Dave Methvin <dave.meth...@gmail.com> wrote:
> How about this?
> $("div[rel]").each(function(){
>    $(this).attr("id", $(this).attr("rel"));
> });

There is no need to create two jQuery objects then throw them away, or
to use the clumsy attr() method.

Just do:

$("div[rel]").each(function(){
  if (!this.id) this.id = this.rel;
});

Of course, it would probably be better to avoid this altogether and
use the rel attribute to make selections to begin with.

Matt Kruse

Reply via email to