最近才發現到這個語法
以前都不知道
typeof
參考 http://msdn.microsoft.com/zh-tw/library/ie/259s7zc1(v=vs.94).aspx
所以如果想驗證這個字串是不是數字就可以用
ex: aa = 123;
alert( typeof(aa) ); //==傳回number
ex: aa = "a123";
alert( typeof(aa) ); //==傳回string
還有一個
如果在上層有一個函數可以先檢查一下
if ( typeof(parent.hideshow) == "function" )
parent.hideshow();
全站熱搜