mercredi 11 février 2015

Any way to change the width of an element in real time?


So Im trying to change the width of a specific element in real time. Meaning that as you scale the browser window, the element changes width along with it.


Now, the way im calculating this width is by using another element as a reference point. So i just basically copy the reference element's width and apply it to my own element. However the problem is that this is only applied after every page refresh instead of a real time change.


Im using the following jquery code:



$("#lists ul").css("width", $("#lists").width());


As you can see, the code is pretty simple. #lists ul is the elements whose width I am attempting to change and #lists is the reference element. My question is, is there a way to achieve this effect? or should I use a different approach? thanks for the help!





Aucun commentaire:

Enregistrer un commentaire