請問同學這是什么意思??function $(id){ return typeof id==='string'?document.getElementsById(id):id; }是什么意思
請問同學這是什么意思??
function $(id){? return typeof id==='string'?document.getElementsById(id):id;? }是什么意思
請問同學這是什么意思??
function $(id){? return typeof id==='string'?document.getElementsById(id):id;? }是什么意思
2015-12-08
舉報
2015-12-08
function $(id){? return typeof id==='string'?document.getElementsById(id):id;? }
$ ?函數名。
id 參數
如果傳入的id是字符串類型的。返回 document.getElementById(id)
你的代碼里document.getElementByid 寫錯了。多了個s
如果不是 直接返回 id
2016-12-15
這個叫三目運算符,百度一下就知道了。他的作用和if....else...的一樣的? 條件(xxxx)?xxxxxx:xxxxx
2015-12-08
定義名為$的函數,參數是id,函數內返回值當id的類型是string時返回document.getElementById(id),不是string時返回id自身