jQuery Question

Discussion in 'Web Design and Development' started by CANEHDN, Apr 4, 2011.

  1. macrumors 6502a

    CANEHDN

    Joined:
    Dec 12, 2005
    Location:
    Eagle Mountain, UT
    #1
    Hey guys. Have a question about jQuery. Here is what I'm doing.

    I have a dropdown. When someone selects an option from the dropdown, jquery pulls some info from another file and displays it on the page. This works fine. This other file contains a div with an id. I then want to perform an action with that id, using jQuery. Since the id isn't present on the page during load, jQuery doesn't see any action performed on the id placed after the page loaded.

    The id is; id="checkStockNum".
    My jQuery is:
    Code:
    $("#checkStockNum.click(function () { alert("test"); });
    How do I get the id to be recognized by jQuery after the page has loaded and once it's placed on the page. I hope that makes sense. I'm not even sure how to google this.

    Any help would be greatly appreciated.
     
  2. web_god61, Apr 4, 2011
    Last edited: Apr 6, 2011

    macrumors regular

    web_god61

    Joined:
    May 14, 2004
  3. macrumors newbie

    Joined:
    Jul 27, 2005
    Location:
    Michigan
    #3
    Try this.

    $("#checkStockNum").live("click", function(){alert();});
     
  4. CANEHDN, Apr 4, 2011
    Last edited: Apr 4, 2011

    thread starter macrumors 6502a

    CANEHDN

    Joined:
    Dec 12, 2005
    Location:
    Eagle Mountain, UT
    #4
    That worked. Thanks so much. It was .live. You are awesome.
     

Share This Page