Home > Web Front-end > JS Tutorial > js solution to get null object_javascript skills

js solution to get null object_javascript skills

WBOY
Release: 2016-05-16 17:13:18
Original
1376 people have browsed it

The data dynamically output on the page, this is the data obtained by ajax. I want to display it on the page

Copy the code The code is as follows: >
success:function(data){
var arr = data.split('_');
var numArr = arr[0].split(",");
var numStr = "";
If(numArr.length==undefined || numArr.length==0){
$("#phonenolist").html('Sorry, no corresponding number was found! ');
}else{
}else{ for(var i=0;i numStr = "
  • numArr[i].toString() ",n_" i ");" class='buy'>"
    numArr[i].toString().substring(0 , 3)                                                            numArr[i].toString(). substring(7, 11)                                                                                                                          (numStr);
    }
                index = arr[1];                                                              🎜>       }                                                                                                                                                                                                                          ).html("

    " num "

    ");
    $("#" id).addClass("buy").siblings() .removeClass("buy");
    }


    My parameters in js are roughly like this, choose_mobile (number, object id), but when executing js, only the number pops up , there is no ID, so I was very depressed. Later, I asked others for help. In lines 9 and 10 of the code, I added '' single quotes to the two parameters of the method,




    Copy code


    The code is as follows:


    numStr = "
  • numArr[i].toString() "','n_" i "');" class='buy'>"


  • That’s how it worked, let me be nice before I’m confused. The parsing of strings by js is still different from the parsing of numeric strings. They can be distinguished so clearly.
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template