1

SAMPLE VALUE A=0,B=1,C=2,D=3 From passed Input Value

var data=[
  $('#a').val(),
  $('#b').val(),
  $('#c').val(),
  $('#d').val(),
];

Getting Max Value

 var getMaxValue=Math.max.apply(this,data);

// Tried This but gives me -1 index //

 var getindex= $.inArray(max,getMaxValue);
lagbox
  • 48,571
  • 8
  • 72
  • 83
Kiruaaa
  • 191
  • 1
  • 12
  • 3
    See duplicate reference. Also realise that if `data` is numeric (you didn't specify a complete example, so we don't know), then it will not match (you'll get -1), because `.val()` returns a string, never a number. – trincot Nov 17 '19 at 19:03
  • @trincot thank you this gives me of idea converting to parse int – Kiruaaa Nov 17 '19 at 19:10
  • solved my problem ty – Kiruaaa Nov 17 '19 at 19:11

1 Answers1

1

Try this

var data=[0,1,2,3];
var getMaxValue=Math.max.apply(this,data);
var getindex= $.inArray(getMaxValue,data);
console.log(getindex);  
Erik Philips
  • 53,428
  • 11
  • 128
  • 150