jQuery indexof不起作用 [英] Jquery indexof Not Working

查看:236
本文介绍了jQuery indexof不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

团队,

我的调味品不起作用,请让我知道.
请帮助

Hi Team,

My Condiion are Not Working Please Let me Know .
Kindly Help

var obj = ['+919820530598', '+918869472915', '+912222551515', '+912212315', '+912265561115', '+4471628111', '+4471613222', '4471245678'];
            var checkNumber = obj;
            $.each(checkNumber, function (i, val) {
                debugger;
                if (val.indexOf(9) == 1) {
                    debugger;
                    if (val.indexOf(1) == 11 && val.indexOf(5) == 12) {
                        debugger;
                        alert(val + ' is a Indian Mobile Number ');
                    }
                    else {
                        alert(' Mobile Number ' + val + ' Not in the List of UK and India ');
                    }
                }
                else if (val.indexOf(+44) == 1) {
                    debugger;
                    if (val.indexOf(6) == 3 && val.indexOf(8) == 5) {
                        debugger;
                        alert(val + ' is a UK Mobile Number ');
                    }
                    else {
                        alert(' Mobile Number ' + val + ' Not in the List of UK and India ');
                    }
                }

            })




在此先感谢
harshal




Thanks in Advance
harshal

推荐答案

.each(checkNumber,function(i,val){ 调试器; 如果(val.indexOf( 9 )== 1 ){ 调试器; 如果(val.indexOf( 1 )== 11 && val.indexOf( 5 )== 12 ){ 调试器; alert(val + ' 是印度手机号码'); } 其他 { alert(' 手机号码' + val + ' 不在英国和印度列表中(); } } 其他 如果(val.indexOf(+44)== 1 ){ 调试器; 如果(val.indexOf( 6 )== 3 && val.indexOf( 8 )== 5 ){ 调试器; alert(val + ' 是英国手机号码'); } 其他 { alert(' 手机号码' + val + ' 不在英国和印度列表中(); } } })
.each(checkNumber, function (i, val) { debugger; if (val.indexOf(9) == 1) { debugger; if (val.indexOf(1) == 11 && val.indexOf(5) == 12) { debugger; alert(val + ' is a Indian Mobile Number '); } else { alert(' Mobile Number ' + val + ' Not in the List of UK and India '); } } else if (val.indexOf(+44) == 1) { debugger; if (val.indexOf(6) == 3 && val.indexOf(8) == 5) { debugger; alert(val + ' is a UK Mobile Number '); } else { alert(' Mobile Number ' + val + ' Not in the List of UK and India '); } } })




在此先感谢
苛刻的




Thanks in Advance
harshal


我在这里看到的问题是您正在寻找结果,但忽略了数据.您甚至都没有看过indexOf测试的返回.
第一:
The problem i see here is that you are looking for the result but ignoring the data. You didin''t even looked at the return of the indexOf test.
First:
报价:

在这种情况下,''+ 918869472915''是印度数字,但返回的是False.这是我的问题.如果您检查我没有在此之前提交过此类问题.所以你怎么能说这是一个重复的问题..请检查一下.

In This Condition ,''+918869472915'' is a Indian Number but it returns me False .This is my Problem .If you Check i have not submitted this type of question before this ..so how could you say this is a repeated question ..Please check it.


那是不对的.因为这个:


That''s incorrect. Because this:

报价:

if(val.indexOf(1)== 11&&val.indexOf(5)== 12){

if (val.indexOf(1) == 11 && val.indexOf(5) == 12) {


会发现这样的东西:

+9(1)886947291(5)
--- 2 ------------- 12

您可以使用val.charAt(11)来检查字符在特定位置是否等于所需的值.如果印度数字的末尾总是15,那么您只需检查一下即可.

无论如何,如果您只是寻求解决方案,人们就不那么愿意提供帮助.


Will find something like this:

+9(1)886947291(5)
---2-------------12

You could use val.charAt(11) to check if the character equals to the desired value at a specific position. If the Indian numbers always have the number 15 at the end, you should just check for it.

Anyway, people are less eager to help if you just ask for solutions.


这篇关于jQuery indexof不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆