欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長(zhǎng)資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          jquery中怎么判斷值在不在數(shù)組中

          在jquery中,可以利用inArray()方法來(lái)判斷值在不在數(shù)組中,語(yǔ)法“$.inArray(value,array)”;如果指定值在數(shù)組中,則會(huì)返回該值在數(shù)組的下標(biāo)(索引),如果不在則返回“-1”。

          jquery中怎么判斷值在不在數(shù)組中

          本教程操作環(huán)境:windows7系統(tǒng)、jquery1.10.0版本、Dell G3電腦。

          jquery判斷值在不在數(shù)組中

          在jquery中,可以利用inArray()方法來(lái)判斷值在不在數(shù)組中。

          $.inArray() 函數(shù)用于在數(shù)組中查找指定值,并返回它的索引值(如果沒有找到,則返回-1)。

          利用這個(gè)特性,我們可以通過$.inArray() 函數(shù)在數(shù)組中查找指定值,看看是否返回-1來(lái)判斷值是否在數(shù)組中。

          實(shí)現(xiàn)代碼:

          <script src="js/jquery-1.10.0.min.js"></script> <script> 	var array=[1,2,3,4,5,6]; 	var value=2; 	var vlaue = $.inArray(value, array); 	if(value != -1) { 	  console.log("指定值在數(shù)組中"); 	} 	else{ 		console.log("指定值不在數(shù)組中"); 	} </script>

          jquery中怎么判斷值在不在數(shù)組中

          相關(guān)視頻教程推薦:jQuery教程(視頻)

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)