0

I have following HTML Code:

<input size="18" type="text" name="replacement_phone_1" value="5304407546" disabled>
<input size="18" type="text" name="replacement_phone_1" value="5304407314" disabled>
<input size="18" type="text" name="replacement_phone_1" value="5304407361" disabled>

Jquery code to get the value of all input tag:

var getInputValue = $('input[name="replacement_phone_1"]').attr("value");

However, it is returning only one value i.e 5304407546. I want all values in an array.

sameer
  • 19
  • 5
  • jQuery is kind of becoming obsolete. Just do `Array.from(document.querySelectorAll("input[name=replacement_phone_1]"), ({ value }) => value)`. Make sure you understand [the difference between properties and attributes](/q/6003819/4642212). – Sebastian Simon Dec 21 '22 at 09:39

1 Answers1

-1
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $('input[name*="replacement_phone_1"]').each(function(e){
debugger
        console.log($(this).attr("value"))
    })
});
</script>
</head>
<body>

<input size="18" type="text" name="replacement_phone_1" value="5304407546" disabled>
<input size="18" type="text" name="replacement_phone_1" value="5304407314" disabled>
<input size="18" type="text" name="replacement_phone_1" value="5304407361" disabled>

</body>
</html>
Dhaval Soni
  • 416
  • 3
  • 13