The following code will first select all elements with a space in the class attribute. We could just do $ ('*'), as Blender suggests, but this is less efficient since it initially selects ALL elements on the page, and not just those that are viable candidates (i.e., have a place in the class name).
Also, those cases are considered when there is only one class, but the class attribute has a space in it (this is done using the jQuery $ .trim () method for the class attribute before it is split). Blender does not solve this situation.
$(function(){ var div = $('div[class*=" "]').filter(function(){ var clsArray = $.trim(this.className.split(' '); return clsArray.length > 1; }); div.css('background','yellow'); });
Real-time example: http://jsfiddle.net/udBZy/3/
source share