Bandit Design » Our Design Our Portfolio Contact Us
Tutorials TumbleLog Our Thoughts
Quite often at Bandit Design while we're working on your project, we'll stumble upon interesting or humourous things -- so we thought why not share them with the world!
RSS iPhone Random Archive « Home

Bandit Design

This is a TumbleLog authored at the desks of Bandit Design. We're a small web and graphic design studio based in Wellington, New Zealand.

Visit Bandit Design ยป

1 year ago

jQuery Wrap Not Working?

Are you trying to use .wrap() in jQuery only to find it isn’t working?

Something the docs don’t tell you is that you can only wrap elements that are attached to the DOM! Important.

Take for example:

$("<a href='#'>My Link</a>").wrap("<li></li>").appendTo("ul:first").click(function() { ... } ); // will not work
$("<a href='#'>My Link</a>").appendTo("ul:first").wrap("<li></li>").click(function() { ... } ); // will work fine!
1 note

Loading...