I have 2 or more input type that have clear (reset) button for each field,
HTML
<input type="text" name="text1" class="dummytext" />
<button type="button" class="clear-btn">Clear</button>
<input type="text" name="text1" class="dummytext" />
<button type="button" class="clear-btn">Clear</button>
As I far as I do with jQuery, every time I press the one of the Clear button, every input also being cleared. I just want to clear input type related with each Clear button. Any help?
Thank you. 🙂
Use jQuery’s
prev()method to get the relatedinput:Here’s the fiddle: http://jsfiddle.net/aq3Vg/