Help with wrapping a div around elements
I'm working with an XML feed that I'm displaying using XSLT. Everything is working great except for 1 thing. One of the nodes that I'm using has a bunch of data in it that I need to split into separate divs for the design. jQuery should work wonderfully for it, but my problem is that in the data I'm supplied there is a string that *should* have a <p></p> around it, but it doesn't. So therefore I have no idea how to select it. Can someone help me out with this?
Here is the data that I get:
- <b>Item 1: </b> Item 1 content<br><b>Item 2: </b> Item 2 content<br><b>Item 3: </b> Item 3 content<br><b>Item 4: </b> Item 4 content<br><b>Item 5: </b> Item 5 content<br><b>Item 6: </b> Item 6 content<br>
Here's how I want it to be converted to:
- <div><b>Item 1: </b><p>Item 1 content</p></div>
- <div><b>Item 2: </b><p>Item 2 content</p></div>
- <div><b>Item 3: </b><p>Item 3 content</p></div>
- <div><b>Item 4: </b><p>Item 4 content</p></div>
- <div><b>Item 5: </b><p>Item 5 content</p></div>
- <div><b>Item 6: </b><p>Item 6 content</p></div>
Notice how it's a <div> around each "item" with the content being in a <p>.
Here are some of the ways I've tried, but none of them work.
- <script type="text/javascript">
- $(document).ready(function(){
- //$("br").wrap("<div></div>");
- //$("b + br").wrap("<div></div>");
- //$("b").appendTo("<p class='test'>");
- //$("br").prependTo("</p>");
- /*$("b").each(function(){
- var $this = this;
- $this
- .add( $this.next() )
- .wrapInner("<div></div>");
-
- });*/
- //$('#message p').replace('<b>','<div><b>').replace('</b>','</b><p>').replace('<br>','</p>
- /div>');
- /*
- $('<b>').replaceWith('<div><b>');
- $('</b>').replaceWith('</b><p>');
- $('<br>').replaceWith('</p></div>');
- */
- /*
- var myText = $('#message');
- myText.val( myText.val().replace('<b>','<div><b>') );
- myText.val( myText.val().replace('</b>','</b><p>') );
- myText.val( myText.val().replace('<br>','</p></div>') );
- */
- //$("p").html(html().replace('Language','LANGUAGE>'));
-
- // ALMOST THERE... $('#message p > *').addClass('test');
- });
- </script>
Thanks for your help!