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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.