jQuery: selecting elements with multiple classes?

  1. <tr class=“child”>…
    $(‘.child’) works fine and selects all elements with class “child”

  2. <tr class=“child del”>
    $(‘.child)’ does not work and selects nothing

How can I fix this and select the elements in case of multiple classes? Is there something as a wild card to select any elements containing “child” as one of the classes?

It depends upon how that library uses the parameter that it’s passed. If it can take a regular expression, try:

$(/^child\\s?/)

// or

$(/^child(\\sdel)?/)

Hi.
Try this:


<script type="text/javascript">
$(document).ready(function () {
	$('div[@class*=child]').each(function(i){
			alert(i);
	}
	)
	
});
</script>
</head>
<body>
<div class="child">Test1</div>
<div class="child del">Test1</div>
</body>
</html>

http://docs.jquery.com/DOM/Traversing/Selectors

Bye.

You must be doing something else wrong. jQuery does support multiple classes (look here: http://jsbin.com/ahaxe/edit). Can we see some more of your code?