jquery获取select选中项 自定义属性的值

<select id="serialNo" >

<option value=''1' data-id="001">第一次</option>

</select>

获取data-id的值:

$("#serialNo").attr("data-id");---undefined  不正确

正确写法:

$("#serialNo").find("option:selected").attr("data-id");


原文链接:https://blog.csdn.net/caixiajia/article/details/78141266

posted on 2019-12-23 14:53  yr1126  阅读(621)  评论(0编辑  收藏  举报