jquery 获取 option id的值和多传参数的

html

<tr>
 <td class="label">请选择平台名称</td>
 <td>
 <select name="channel_sn" id="channel_sn" onchange="createOrderSn(this)">
 <option value="0">请选择平台名称</option>
 {foreach from=$platform item=item k=k}
 <option value="{$item.platform_id}" >{$item.platform_name}</option>
 <option hidden="hidden" id="platform_code" value="{$item.platform_code}">{$item.platform_code}</option>
 {/foreach}
 </select>
 </td>
</tr>

js

<script>
 var sel=document.getElementById("channel_sn");
console.log(sel);
var index = sel.selectedIndex; // 选中索引
console.log(index);
var enCode = $(sel.options[index]).attr('en');
//获取平台code
var code = sel.options[index+1].value;
console.log(code);
</script>

效果 js效果

大海技术博客
请先登录后发表评论
  • latest comments
  • 总共0条评论