js 判断 theID 在 另一个字段的值里面 是否存在

解决方案 »

  1.   


    var str = '123'
    var find = '2';
    alert( str.indexOf(find) )
    楼主 说清楚点, theID是怎样的,另一个字段的值又是怎样的。
      

  2.   

    indexof就是看字段是否被包含的  楼上正解啊  楼主应该就是说这个吧 
      

  3.   

    <script type="text/javascript">
        var theID;
        var GetChannelList = function (id) {
            if (id.indexOf(theID)) {
                $.post("/blog/GetChannelList/" + id, function (result) {
                    if (result != "") {
                        theID += id;
                        $("#menu-" + id).append(result);
                    }
                    else {
                        location.replace('/blog/index/' + id);
                    }
                });
            }
        }
    </script>
    我是想  判断theID值在id的值里面是否存在;
      

  4.   

    var theid = 1;
    if($("[id="+theid+"]").length > 0 ){
        console.log("用过");
    }
      

  5.   

    不能那么判断。应该与-1比较。 没找到indexOf返回-1