javascript判断变量是否为空的方法


javascript判断字符串变量是否为空的方法
代码如下
<pre>

if (typeof(ndesc)=="undefined" || ndesc=='' || ndesc==null)
{
ndesc="1111!";
}
</pre>

 

ps:ndesc 变量没有初始化 typeof(ndesc) 都是undefined

 

 

判断数字是否为空

var startv = parseInt($('#myTargetElement').text());
if (isNaN(startv)) {
startv = 0;
}

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM