开发者

Using jQuery to add 2 elements at once using selector syntax

I am using jQuery to dynamically insert combo buttons in a loop. Right now I have the tag successfully getting added, but I also want a line break (<br/>) after each one. How can I accomplish this? Here is what I have so far:

    var input = $('<input>', {
        type: "radio",
开发者_开发问答        name: "phone-format-radio",
        value: i+1,
        text: GetDisplayNumber( format )
    });

    $(id + ' > button').before( input );

the 'id' variable is the ID of my <section> element which contains my dynamically created <input> elements. There is also a <button> element inside of my <section> that is defined in the HTML file and must always remain the last child in my <section> (which is why I use .before().


You can simply use after:

input.after('<br/>');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜