被一段简单的代码折腾崩溃了.
alert(gReturn);
if (gReturn.toUpperCase() == 'N')
{
alert("Hide");
document.getElementById(pSelect).style.display='none';}
else
{
alert("Show");
document.getElementById(pSelect).style.display='block';}但是不管alert出来的是 Y还是N, 始终第二个alert都是Show.
gReturn我用typeof 看过,是string类型的.
在线等.谢谢了.
alert(gReturn);
if (gReturn.toUpperCase() == 'N')
{
alert("Hide");
document.getElementById(pSelect).style.display='none';}
else
{
alert("Show");
document.getElementById(pSelect).style.display='block';}但是不管alert出来的是 Y还是N, 始终第二个alert都是Show.
gReturn我用typeof 看过,是string类型的.
在线等.谢谢了.
要不然就用gReturn.indexOf('n')或者正则表达式
而且这个indexof还是因为我知道目前这个要么是Y要么是N,不是比较两个复杂的字符串,否则还不崩溃啊...我看到有以下介绍,不过我试验,语法都不通过. 唉~~ 难以想象...
**********************************************************************************
equals()和==
equals()方法比较字符串对象中的字符,==运算符比较两个对象是否引用同一实例。
**********************************************************************************
compareTo()和compareToIgnoreCase() 比较字符串
**********************************************************************************
无效字符应该不止一个,难道我用穷举法? 给个解决的办法吧.
function()
{
return this.replace(/^\s+/, '').replace(/\s+$/, '');
}
alert(gReturn);
if (gReturn.trim().toUpperCase() == 'N')
{
alert("Hide"); document.getElementById(pSelect).style.display='none';}
else
{
alert("Show");
document.getElementById(pSelect).style.display='block';}