Hi all,

I need to select all the divs having the classname starting as msg_body. actually the classname is msg_body_3. The last part of the class name of each div will vary as it is an id.

How can i slideup all these divs, class name starting with msg_body using jquery.

Thanks in advance.


I'm not sure that jquery will handle this but there's a simple workaround based on the ability of HTML/DOM elements to have more than one class.

So arrange for all the relevant divs to have an additional class name, eg. <div class="msg_body msg_body_3"> then select with $(".msg_body") .

That should give you what you want.


I just took another look at the jQuery API and there's a better way.

You should be able to use an attributeStartsWith filter, with no need for a second class name.

If I'm reading the API correctly, then this should work: $("div[class^='msg_body_']") .