There is a great plugin designed specifically for handling this kind of data called the metadata plugin. The format in which it operates resembles JSON and can be quite useful when dealing with arrays, such as:
<img src="..." class="isearcher {tags : ['apple', 'banana']}" >
An example of how to use the plugin to access the data is shown below:
var data = $("img").metadata();
data.tags // an array containing both tags
data.tags.length // 2
data.tags[0] // "apple"
You can test this functionality by visiting this link here.
If you are working with HTML5, consider utilizing data attributes, which are not only currently functional but also compliant with HTML5 standards. These attributes allow for storing more complex data structures like arrays and objects, similar to what the metadata plugin offers.