Is there a common method to sync two properties via JavaScript or JQuery.
For example, I have a text field that is 'editable'. On double click, I hide it then show an input box. If the text field changes size, then the input has to change as well in order to maintain the layout. In the past, on a re-size event, I would make sure that I would change the size of both objects and it works fine. Essentially, I manually ensured that whenever the label changes size, I also changed the size of the input box.
Is there a better design pattern than just always setting both sizes? Maybe a listener for when CSS width
changes or something?
Edit #1: Example
I want to make div_one
be constantly checking div_two
's width. When div_two
's width changes, div_one
's width will change its own width to match. To me it sounds like a "cssWidthChangeListener" or something.
Edit #2: Clarification
I don't think my post has been entirely clear up till now as i'm getting good responses for things happening in my examples, but not exactly what i'm getting at. Here is another re-statement of what I want.
How do I create an event/trigger when a css property, class, or attribute changes on an element? When div_one
changes, I want to run a certain function.