SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Jun 2004
    Location
    UK
    Posts
    605
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Jquery traversing issue

    Hi,

    I'm struggling a little with jquery traversing. What I'd like to do is alert the 'action' attribute value of a form when one of it's inputs has been blurred.

    e.g.
    Code:
    <table>
      <form action="1.asp">
        <tr>
          <td><input type="text" value="test1" /></td>
          <td><input type="text" value="test2" /></td>
        </tr>
      </form>
      <form action="5.asp">
        <tr>
          <td><input type="text" value="test3" /></td>
          <td><input type="text" value="test4" /></td>
        </tr>
      </form>
      <form action="3.asp">
        <tr>
          <td><input type="text" value="test5" /></td>
          <td><input type="text" value="test6" /></td>
        </tr>
      </form>
    </table>
    So, for example, if someone changed the first input value and blurred it, an alert would say "1.asp". If they did the same for the last input it would alert "3.asp".

    Does anyone know how to do this with jquery?

    Thanks for any help folks...

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like this...
    Code Javascript:
    jQuery(document).ready(function(){
        $('form input').blur(function(){
           var formAction = $(this).parents('form').attr('action');
           alert(formAction);
        });
    });
    Hope that helps.
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Guru
    Join Date
    Jun 2004
    Location
    UK
    Posts
    605
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perfect, thanks, that's really neat!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •