jquery - Alternative to multiple identical IDs in the same HTML document -


i know repeated use of identical ids in 1 html document bad practice.

how can avoid this, if have elements performing same functions, , need quick access?

for example:

<form id='dialog_setting_dns-form'>     <label>address:</label>     <input name="address" id="address"/> </form> <form id='dialog_static'>     <label>address:</label>     <input name="address" id="address"/> </form> 

use class instead of id in situation

<form id='dialog_setting_dns-form'>     <label>address:</label>     <input name="address" class="address" /> </form>  <form id='dialog_static'>     <label>address:</label>     <input name="address" class="address" /> </form> 

you select class in jquery $('.address') opposed using id $('#address').


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -