Jump to content

Unobtrusive JS but with multiple occasions on a page.


johnsmith153

Recommended Posts

I have a tooltip which uses a little bit of non-essential JS.

 

I want to use JS unobtrusively, apply an id to the tooltip and let JS do it the right way.

 

The problem is I could need more than one tooltip on a page, and I understand that an id should be uniquely applied.

 

If there was only ever a maximum of one item per page then this would be simple.

 

The same could be asked for any button on a page. Imagine I wanted to replace the button with a 'loading please wait' image. I would hope to apply an "id='please-wait-button'" to any button needing it, multiple times on a page, and let JS do it unobtrusively, but again, I should't use multiple id's.

 

What's the best way to do this?

 

What about using getElementByName? Can I apply a name to every tooltip / every button and call it that way? Is that the right way / best way?

 

Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.