Searching JavaScript objects
With objects being the main method of holding data within your application, it can be very useful to be able to find objects matching a certain criteria. jQuery does not provide a direct method for us to search through objects and arrays of objects; however, we can easily create this functionality.
Getting ready
Using your favorite text editor, create a blank HTML document named recipe-4.html
, and ensure that you have the latest version of jQuery installed. Add the following HTML code to this HTML file:
<!DOCTYPE html> <html> <head> <title>Chapter 3 :: AJAX & JSON</title> <script src="jquery.min.js"></script> <script> </script> </head> <body></body> </html>
Ensure that you update the reference to the jQuery library to point out the location where it is saved on your computer. This HTML page provides us with a web page where we can execute JavaScript for this recipe.