假设我有这套 HTML 标记和 CSS
#CSS
.inputhelp_text { background: #000; color: #fff; }
.nodisplay { display: none; }
<input class="inputhelp" id="firstname" /><span class="inputhelp_text nodisplay" id="help_firstname">Write in your firstname</span>
<input class="inputhelp" id="lastname" /><span class="inputhelp_text nodisplay" id="help_lastname">Write in your lastname</span>
使用 jQuery,我需要将一个函数绑定到所有输入字段(我猜是使用 jQuery 的 EACH 函数),这样当我单击输入字段时,它应该将每个跨度的类切换为仅“inputhelp_text”。我已经让它在每个字段的两个单独的函数中工作,但由于我有很多字段,我知道有更好的方法来解决它。
有什么建议么?