First, a function that does the list querying:
// get the list by it's name from the root site level
// Get the current client context to start. Most things run from the client context.
// traverse up through the site to the root level, and get the list called 'my-list'.
// the root level isn't required, you can get a list from your current site level if you want, just use get_web() instead of get_site().get_rootWeb()
myList = clientContext.get_site().get_rootWeb().get_lists().getByTitle(
// use a standard syntax CAML query to filter your results and the fields returned if required, by adding the following, or passing parameters to the load command below
// You can leave out this line if you just want to return the entire list.
'<View><Query><Where><Eq><FieldRef Name="myField"/><Value Type="Text">myValue</Value></Eq></Where></Query><ViewFields><FieldRef Name="myField1"/><FieldRef Name="myField2"/></ViewFields></View>'
// add your query to the getItems command for your list
.collListItems = myList.getItems(query);
// issue the load command, these can be batched for multiple operations
// execute the actual query against the server, and pass the objects we have created to either a success or failure function
// Do something useful like loop through your returned list items and output them somewhere
// create an enumerator to loop through the list with
// loop through the list items
oListItem = listItemEnumerator.get_current();
// do something with this here. Coupled with a platform like jQuery, you could do all kinds of great things
strHtml += oListItem.get_item(
// output your html somewhere here.
// do something to alert the user as to the error here.