Reputation: 199
if i have
<input type="text" class="form-control" id="nama" name="nama" value="blabla">
I can get value by
var v_nama = $('input:text[name=nama]').val();
but if I have
<input type="number" min="0" class="form-control" id="jmlh" name="jmlh" value="4">
jQuery cant do this
var v_jmlh = $('input:number[name=jmlh]').val();
I got warning : Uncaught Error: Syntax error, unrecognized expression: unsupported pseudo: number
so how I can get the value of a input number type ??
Upvotes: 1
Views: 4950
Reputation: 1137
Use type as JQuery attribute
var v_jmlh = $('input[type=number][name=jmlh]').val();
Upvotes: 0
Reputation: 59232
You've to use attribute selector as jQuery doesn't specially provide pseudo-selector :number
var v_jmlh = $('input[type=number][name=jmlh]').val();
But anyway, since you've the id
assigned, you'd be better off using $('#jmlh')
as it's the fastest way using jQuery.
Upvotes: 3