My input elements are followed by a div. I would like to set the width of that div to be that of the preceding input element.
<input type="text" class="input" size="100" name="data"/>
<div class="inputHelp"> enter data above </div>
<input type="text" class="input" size="80" name="moredata"/>
<div class="inputHelp"> enter more data above </div>
In each instance, the class .inputHelp should have the same width as the input element before it.
Using the next selector, I was able to grab the width of input elements followed by the inputHelp div. However, when attempting to set the width of the following inputHelp div, it instead set the width of ALL inputHelp divs on the page. How can I limit it to only set the width of the next inputHelp, and then iterate through all the other input + inputHelp combinations on the page?
Here's my current JQuery code:
$('.input + .inputHelp').width( $('.inputHelp').prev('.input').width() );