For the following jQuery code:
$("#select").change(function() {
$("#output").load("/output/", {}, function(data) {
// I want to extract the value of an element in data
});
});
The content of data is:
<div>
Something
</div>
<input type="hidden" name="ajax-output" value="100" />
I want to get the value ajax-output from the data output. How can I do that using jQuery?
To get it directly, since it’s at the root, you need
.filter(), like this:Or get it from the one you just inserted (via the
.load()call itself) using.find():