1.input获取后缀名

var fileName = $("input[type='file']").val();//获取上传的文件(单个)
var extName = fileName.substr(fileName.lastIndexOf(".") + 1).toLowerCase();//获取后缀名
if(extName != "xls" && extName != "xlsx") {//判断格式
    $.messager.alert('', '只能导入.xls或者.xlsx格式的文件!', 'info');
     return;
}    

2.select通过text获取option(text应该为唯一值)

$("#select").find(":contains('"+text+"')").attr("selected","true");

jq选择器(:contains)

:contains 选择器选取包含指定字符串的元素。

例:

选择所有包含 "is" 的 <p> 元素:

$("p:contains(is)")

  

相关文章:

  • 2021-07-19
  • 2022-12-23
  • 2021-12-18
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2021-09-27
  • 2021-07-20
  • 2022-12-23
相关资源
相似解决方案