-3

I want to check if my array contains the Value Input, i want something like that, anyone have an idea on how to do that ?

if(jQuery.inArray($('#ValueInputTitle').val, variableValueInput) !== -1)
	{
    console.log("is in array");}
	else {
    console.log("is NOT in array");
}

3
  • 3
    val is a function so use val(), assuming variableValueInput is an array you have a typo Commented Jul 9, 2018 at 12:23
  • variableValueInput.indexOf($('#ValueInputTitle').val()>=0) Commented Jul 9, 2018 at 12:24
  • api.jquery.com/jQuery.inArray check this..complete guide is there on jquery page... Commented Jul 9, 2018 at 12:24

1 Answer 1

1

You can use this,

if(jQuery.inArray($('#ValueInputTitle').val(), variableValueInput) !== -1)
    {
    console.log("is in array");}
    else {
    console.log("is NOT in array");
}
Sign up to request clarification or add additional context in comments.

1 Comment

Firstly please explain your answers to the OP in order to educate them. Just providing code helps no one in the long term. Also note that this issues is a very basic typo, which should be closed as such.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.