The $.inarray () function searches the array for the specified value and returns its index value. Returns 1 if the value does not exist in the array;The $.inarray (Value,array)--value is the value to look for, and the array is the one being looked
This article mainly introduces the inArray method precautions in jQuery, and analyzes the precautions for inArray method variable judgment in jQuery in the form of examples, for more information about how to use the inArray method in jQuery, see the
The following describes how to use the inArray () function in jquery:
The Code is as follows:
$. Get ('aaaaa. ashx', null, function (d ){// Assume that the value returned by d is 1, 3, 54,67.Var arr = d. split (',');$. InArray (3, arr) =-1 //
Precautions for inArray method in jQuery: jqueryinarray
This article describes the inArray method precautions in jQuery. We will share this with you for your reference. The details are as follows:
Jquery provides great convenience for web
For example:The code is as follows:$.get (' Aaaaa.ashx ', null,function (d) {Assume that the value returned by D is 1,3,43,23,54,67var arr = d.split (', ');$.inarray (3,arr) ==-1//trueWhy is that?If it is written like thisvar arr = eval (' [' +d+ ']
For example:Copy codeThe Code is as follows:$. Get ('aaaaa. ashx', null, function (d ){// Assume that the value returned by d is 1, 3, 54,67.Var arr = d. split (',');$. InArray (3, arr) =-1 // true// Why?// If you writeVar arr = eval ('[' + d + ']');
For example:
Copy codeThe Code is as follows: $. get ('aaaaa. ashx', null, function (d ){
// Assume that the value returned by d is 1, 3, 54,67.
Var arr = d. split (',');
$. InArray (3, arr) =-1 // true
// Why?
// If you write
Var arr = eval ('[' +
This article analyzes the Inarray method in jquery. Share to everyone for your reference, specific as follows:
jquery provides a great convenience for web developers, and the purpose of this article is to remind you to be cautious about the inarray
jquery inarray makearray Merge unique array function operation instance
$.inarray (Val,array) determines whether the value exists in an array [common]Explanation: Determines the position of the first parameter in the array, counting from 0 (if not
This article introduces the jQuery array ($. each, $. grep, $. map, $. merge, $. inArray, $. unique, $. makeArray) for more information about the usage of processing functions, see.
1. $. each (array, [callback]) traversal [common]
Explanation:
For example:
Copy Code code as follows:
$.get (' Aaaaa.ashx ', null,function (d) {
Suppose D returns a value of 1,3,43,23,54,67
var arr = d.split (', ');
$.inarray (3,arr) ==-1//true
Why, Why?
If it's written like this
1. $.each (array, [callback]) traversal [common]
Explanation: Unlike the $ (). each () method of the JQuery object, this method can be used to sample any object. The callback function has two parameters: the first is the index of the member or
jquery inarray () function detailed
Jquery.inarray (Value,array)Determines the position of the first parameter in the array (returns 1 if not found).
Determine the index of the ' the ' the ' the ' the ' parameter in ' array ( -1 if not
Today I met a thief with a broken egg:
1. I click events from a drop-down list select to get the value of the options
Copy Code code as follows:
var product_id = $ (this). Val ()
Console.log out is found to be a number of
Today, I encountered a problem about broken eggs:1. I click an event from a drop-down list to obtain the value of options.Copy codeThe Code is as follows:Var product_id = $ (this). val () Console. log is an array, for example, ["51"]Then I made the
Get the value of the drop-down list box is an array, and then use product_id to match whether it is contained in an array. If you are interested, do not miss the problem of a zombie today:
1. I click an event from a drop-down list to obtain the
This article mainly introduces the use example of the zf framework InArray checker. For more information, see
This article mainly introduces the use example of the zf framework InArray checker. For more information, see
The Code is as
There are several uses for purely recording:jquery grep () filter Traversal array$ (). Ready ( function () { var array = [1,2,3,4,5,6,7,8,9]; var filterarray = $.grep (array,function (value) { return value > 5;//filter out
Simply record the following several uses:
jquery grep () filter Traversal array
$ (). Ready (
function () {
var array = [1,2,3,4,5,6,7,8,9];
var filterarray = $.grep (array,function (value) {return
value > 5;//filter for
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.