Traversing - $(this).parent().prev().(".replace_no").val("1") - correct way

Traversing - $(this).parent().prev().(".replace_no").val("1") - correct way

Hi... I'm trying to traverse using this method... which doesn't work

  1. $(this).parent().prev().(".replace_no").val("1")

Upon clicking something, I want to change this value:
  1. <p><label>Replace amount:</label><input type="text" class="replace_no" value="CHANGETHIS" /></p>
  2. <p><img id="button" src="btn.jpg" /></p>


So I basically want to go to the previous P, then change the value of the class "replace_no" inside here

I've also tried this, which doesn't work:

  1. $(this).parent().prev( function() {  
  2.         $(".replace_no").val("1");
  3. });


This is ultimately one of the things I just do not understand and I can't seem to find any documentation on it... so I'm assuming its common sense that I do not possess...

Thanks