javascript - Changing value of an attribute using jQuery -
i having file input field:
<input class="uploadreptctrl" id="lang_file_1" name="photo[[1,312,3]]" type="file">
i trying change third element of array in name
attribute becomes:
<input class="uploadreptctrl" id="lang_file_1" name="photo[[1,312,4]]" type="file">
how possible?
try this
$('#lang_file_1').attr('name','photo[[1,312,4]]')
https://jsfiddle.net/jzzl1d2r/
you can store value in variable , set as
var = 4; $('#lang_file_1').attr('name','photo[[1,312,'+a+']]')
https://jsfiddle.net/jzzl1d2r/1/
as want 3rd number increment , assign again can following
var numberpattern = /\d+/g; var string = $('#lang_file_1').attr('name'); var = string.match( numberpattern ); $('#lang_file_1').attr('name','photo[[1,312,'+(++a[2])+']]');
Comments
Post a Comment