【问题标题】:jQuery createElement then append others insidejQuery createElement 然后在里面追加其他的
【发布时间】:2013-08-19 05:42:45
【问题描述】:

我正在尝试自定义一些操作系统 jQuery 来创建一个 div,然后在其中添加另一个“createElement”,以便我可以使用 css 进行样式设置。我在这里超出了我的深度,任何帮助都会很棒。这是我的代码:

container = $(doc.createElement(options.containerTagName)).attr({
    id: namespace + '-' + element.attr('id'),
    'class': options.containerClassName
}).insertAfter(element);

$(doc.createElement('span'))
    .appendTo(container)
    .append(element);

uploadwrapper = $(doc.createElement('div'))
    .attr('class', 'btn_upload_wrapper')
    .insertAfter(container);

$(doc.createElement('input'))
    .attr(options.buttonAttributes)
    .attr('type', 'button')
    .appendTo(uploadwrapper);

$(doc.createElement('i'))
    .attr('class', 'icon-folder-open')
    .appendTo(uploadwrapper);

textElement = $(doc.createElement(options.textTagName))
    .attr(options.textAttributes)
    .appendTo(uploadwrapper);

我能够回答我自己的问题,见下文

container = $(doc.createElement(options.containerTagName)).attr({
    id: namespace + '-' + element.attr('id'),
    'class': options.containerClassName
}).insertAfter(element);

$(doc.createElement('span'))
    .appendTo(container)
    .append(element);

$(doc.createElement('div'))
    .attr('class', 'btn_upload_wrapper')
    .appendTo(container);

$(doc.createElement('input'))
    .attr(options.buttonAttributes)
    .attr('type', 'button')
    .appendTo('.btn_upload_wrapper');

$(doc.createElement('i'))
    .attr('class', 'icon-folder-open')
    .appendTo('.btn_upload_wrapper');

textElement = $(doc.createElement(options.textTagName))
    .attr(options.textAttributes)
    .appendTo('.btn_upload_wrapper');

【问题讨论】:

  • 能够回答我自己的问题。请关闭此问题
  • 为什么不将您的答案(作为答案,而不是对您的问题的编辑)发布到您的问题中?这样将来对其他人有用; Stack Overflow 旨在帮助他人和您自己,如果您的问题被认为将来对其他人有用,它可能会被关闭。
  • 所以回答它并标记为接受。
  • 因为我在知道或找到答案之前就问了这个问题。找到问题的答案后,我将其发布为编辑而不是评论,以便于阅读。我希望我的回答可以帮助其他找到我问题的人。
  • 另外,我无法回答自己的问题,也无法以正常方式将其标记为已接受,因为这是我自己的问题。

标签: jquery appendto createelement


【解决方案1】:

能够回答我自己的问题。请关闭此问题

container = $(doc.createElement(options.containerTagName)).attr({
    id: namespace + '-' + element.attr('id'),
    'class': options.containerClassName
}).insertAfter(element);

$(doc.createElement('span'))
    .appendTo(container)
    .append(element);

$(doc.createElement('div'))
    .attr('class', 'btn_upload_wrapper')
    .appendTo(container);

$(doc.createElement('input'))
    .attr(options.buttonAttributes)
    .attr('type', 'button')
    .appendTo('.btn_upload_wrapper');

$(doc.createElement('i'))
    .attr('class', 'icon-folder-open')
    .appendTo('.btn_upload_wrapper');

textElement = $(doc.createElement(options.textTagName))
    .attr(options.textAttributes)
    .appendTo('.btn_upload_wrapper');

【讨论】:

    猜你喜欢
    • 2012-10-06
    • 2012-02-08
    • 1970-01-01
    • 2011-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-28
    • 2012-12-19
    相关资源
    最近更新 更多