View Code
新手 好像代码布局有点乱 没有调好
function GetValueByKey(strs, key, sp)
{
key = key.toLowerCase();
strs = strs.toLowerCase();
if (strs.indexOf(key + "=") > -1)
{
var result;
var s = strs.substring(strs.indexOf(key + "="));
if (s.indexOf(sp) != -1)
{
result = s.substring(s.indexOf(key + "=") + key.length + 1, s.indexOf(sp));
} else
{
if (s.indexOf(key + "=") != -1)
{
result = s.substring(s.indexOf(key + "=") + key.length + 1);
}
}
}
return result;
}
// var strs = "A=1,B=2,c=3,d=4,ee=";
// document.write( GetValueByKey(strs, "B", ","));
--value 2