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])+']]'); 

https://jsfiddle.net/jzzl1d2r/3/


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -