你的心如利箭 在风中笔直的飞翔
github DNS ALEXA CDN
jquery JS CSS CSS3 HTML5 svg php --- isux w3cplus

21270

  博客园  :: 首页  ::  ::  ::  :: 管理

 

 

判断一个变量是否存在:   2016-3-30

if(typeof(GP)!=="undefined"){
    offerIndex.dropArea(GP,GC1);//省市下拉菜单初始化
}

 

判断一个元素是否存在:   2016-3-30

<script type="text/javascript" src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
    var s=$("#button").length;
    alert(s);  //为0就是不存在
});
</script>

 

 

 

js 中的in_array(判断某个元素是否在js数组中)

js 中的in_array(判断某个元素是否在js数组中)
Array.prototype.S = String.fromCharCode(2);  
Array.prototype.in_array = function(e) {  
    var r = new RegExp(this.S+e+this.S);  
    return (r.test(this.S+this.join(this.S)+this.S));  
}; 
 
var pre_arr = new Array();
pre_arr .in_array('test');//存在返回true 否则false

from: http://hi.baidu.com/bing2liuliu/item/7d9243628eb2712269105ba9

posted on 2013-12-13 13:34  bjhhh  阅读(245)  评论(0编辑  收藏  举报