View Full Version : jQuery Question

Apr 4, 2011, 02:57 PM
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: $("#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.

Apr 4, 2011, 04:28 PM
You try $(function(){ //code... });

Apr 4, 2011, 05:06 PM
Try this.

$("#checkStockNum").live("click", function(){alert();});

Apr 4, 2011, 05:40 PM
That worked. Thanks so much. It was .live. You are awesome.