直接上实例代码:
<img id="brandIcon" src="https://www.mbkfw.com/static/image/lazy.gif" class="lazy" original=""" /> <script language="JavaScript" type="text/javascript" > function setBeerIcon() { var classimg = $("#beer").find("option:selected").attr('data-img'); $("#brandIcon").attr("src",classimg); } </script> <form> <select id="beer" onChange="setBeerIcon();" <option value="1" data-img="/img/1.jpg">项目一</option> <option value="2" data-img="/img/2.jpg">项目二</option> <option value="3" data-img="/img/3.jpg"">项目三</option> </select> </form>