0

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.
Jino

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by ShawnCplus
0

Jino,

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.

Airshow

1

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_']") .

Airshow

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.