aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes jQuery wrapAll()? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "jQuery wrapAll()?" Watch "jQuery wrapAll()?" New topic
Author

jQuery wrapAll()?

Mike Anthony
Greenhorn

Joined: Jul 06, 2009
Posts: 11
I want to insure that all of my fieldsets have a <div> tag enclosing all of the other elements (except the <legend> tag) so I was attempting to use jQuery's wrapall() to do this.

So if I have the following:



then after the wrapAll() is applied I want it to look like the following:



My latest attempt was the following:



However this is not working and I am getting strange results.
It behaves as if it has wrapped all of the elements of all of the fieldsets into one big <div> as opposed to wrapping the elements of each individual fieldset with <div> tags
I have not been able to get the results that I am after.

Can anyone help me out here?

Thank you!
--Michael
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

Could you please indent your code? It'd make it easier to see the structure.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mike Anthony
Greenhorn

Joined: Jul 06, 2009
Posts: 11
Sure I can. Sorry about that, I thought that it auto-indented in my first post and I wasn't paying attention.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

This worked for me:



GenRocket - Experts at Building Test Data
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
A few ways to do it [doubt you can do it as a 1 liner]



Eric
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Eric, is there a difference in mine and your 3rd option?
Mike Anthony
Greenhorn

Joined: Jul 06, 2009
Posts: 11
Thanks for all of the help!
I think that I have it working well now. More testing will tell, but it looks good.
I guess that I just need to get this syntax down. It looks like there are so many different ways to accomplish the same thing, I guess this is part of my confusion.
I should probably work through a jQuery tutorial instead of trying to pick this stuff up on the fly...
Thanks again!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Gregg, I never saw your code. I thought I would run the test and see what happens if you run the selector with 100 of the fieldsets on the page.

Run #E #3E #2E #1Gregg
1185206197214
2188200199206
3186205209209
avg187204202209


A good rule of thumb with JQuery is get as specific as you can with the initial selectors and keep the logic inside the each as minimal as you can.

Eric
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Good stuff Eric, thanks.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Gregg Bolinger wrote:Good stuff Eric, thanks.


The good news here is difference of < 1ms with all of the options. [Note tests with FF3.0.10]

Eric

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jQuery wrapAll()?