Can I set the id for a layer? I see I can set the name, but id seems like the right attribute to set. .
Nope, id is read only
As far as I know it's not something you would ever need or want to set
You can use the (internal) _element property of layers to directly get the HTML element, no querying necessary.