I want to replace a html element with jQuery’s load method and want to focus an input element within the loaded elements with the class .focus. It is possible that there is more than one element with the class .focus, so it is important to select within the loaded element.
I tried the following but it doesn’t work:
paragraphToBeReplaced.load(
"/some/url",
function(event) { event.data.contents(".focus").focus(); }
);
How can I set the focus to a loaded element? I’m using jQuery 1.7.1.
Within the load callback
thisis the element that new content is being loaded into. Using find() can search within this element for your class