Unknown Error
Unknown Error

Reputation: 797

How do I retrieve some input value in jQuery

Example my temporary input is 1,2,3

<input type="hidden" id="temp" name="temp" value="1,2,3">

var tempvalue = $("#temp").attr("value")

With jQuery it's possible to get the number 3 only for tempvalue? So 1,2, will be removed while onclick action.

Upvotes: 0

Views: 58

Answers (3)

David Rasuli
David Rasuli

Reputation: 832

you can get the whole value and use it as an array OR use jQuery.each() to get the number you want

Upvotes: 0

Royi Namir
Royi Namir

Reputation: 148514

try this:

var tempvalue = $("#temp").attr("value").split(',')[2]

Upvotes: 1

Roland Mai
Roland Mai

Reputation: 31077

var parts = tempvalue.split(',');
var third_value = parts[parts.length-1];

Upvotes: 2

Related Questions