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
Post a Comment