mercredi 4 février 2015

How to define JS variable as the width of a div?


Vote count:

0




How do you assign width to a div that is user-defined? I have a function that for simplicity's sake is the following:



drawHistogram(..., widthVar, heightVar, canvasName) {
$("#" + canvasName).css({
width: widthVar, // assigns div width
height: heightVar // assigns div height
});
myHistogram.width = widthVar;
myHistogram.height = heightVar;
}


Currently I can't actually use canvasName in the myHistogram.width/height statement, so I have to assign the div as myHistogram or whatever is written in the xx.width/height statement. How can I replace myHistogram with canvasName? I tried canvasName.width/height, but it hasn't worked. Thanks!



asked 37 secs ago







How to define JS variable as the width of a div?

Aucun commentaire:

Enregistrer un commentaire