jquery - passing an input text value to another and modify width of an image -


i have image (vue) id , created 2 input type text,one id (hauteur) , other (largeur). try catch value written in (hauteur) text , pass image (vue) , take height of image , pass (largeur) input text. created div button (valider) , added event .click .

$(document).ready(function() {   $("#valider").click(function(){      var largeur=$('input[name=largeur]').val();      $('#vue').css('width','largeur');     var hauteur=$("#vue").css('height');     $('input[name=hauteur]').val('hauteur');   }); }); 

but have hauteur(as string not number) value in input.

you're passing hauteur string literal not variable. remove quotes.

in line

$('input[name=hauteur]').val('hauteur'); 

change 'hauteur' hauteur

$('input[name=hauteur]').val(hauteur); 

secondly change

$('#vue').css('width','largeur'); 

to

$('#vue').css('width', largeur); 

as assignment variable. shouldn't use .css('height'). should use .height().

if use .css(), retrieving value of style have applied. not actual height of rendered image in browser.

also, if have id largeur applied input, don't need use name select input, select have #vue:

$('#largeur') 

the same stands hauteur.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -