开发者

How do I create a DIV with Jquery around this pre-exisitining code?

开发者 https://www.devze.com 2023-03-29 07:29 出处:网络
Here is the code I have, hopefully the selection I\'ve given is enough. var $nextHt开发者_JAVA技巧ml = $(\'<a href=\"\" class=\"bx-next\">next</a>\');

Here is the code I have, hopefully the selection I've given is enough.

var $nextHt开发者_JAVA技巧ml = $('<a href="" class="bx-next">next</a>');
var $prevHtml = $('<a href="" class="bx-prev">prev</a>');

The code above creates two links:

<a href="">next</a><a href="">prev</a>

Right now, the two anchor tags this has created are floating freely within it's parent div, which also holds many other objects. This makes it hard to stylize the two anchors together.

How can I wrap the two anchors in a div together so the output HTML is this:

<div class="control-wrap">
    <a href="">next</a><a href="">prev</a>
</div>

Thanks for the help! My lack of Jquery knowledge is killing me...


$("<div>").addClass("control-wrap").append($nextHtml).append($prevHtml);
0

精彩评论

暂无评论...
验证码 换一张
取 消