admin管理员组文章数量:1404927
// `shipment` is unique number
var `shipment` = this.Shipment;
$('<div id=' + this.Shipment + '>' + this.Shipment +'</div>').click(function () {
_Services.invoke({
method: 'GetOrdersGrid',
data: { ShipmentNumber: shipment },
success: function (shipment) {
paintOrders(`shipment`);
the function gets a number of div and needs to put the TEXT into the div
<div id="11626">TEXT</div>
<br>
<div id="12109">TEXT</div>
ERROR: ("#" + items).append is not a function [Break On This Error] ('#' + items).append($(container));
WHEN i use the sollar sign $('#' + items).append($(container));
ERROR uncaught exception: Syntax error, unrecognized expression: #[object Object]
WHEN i use without the #
$(items).append(container); or $(items).append($(container));
(this[0].ownerDocument || this[0]).createDocumentFragment is not a function
[Break On This Error] var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(),
// `shipment` is unique number
var `shipment` = this.Shipment;
$('<div id=' + this.Shipment + '>' + this.Shipment +'</div>').click(function () {
_Services.invoke({
method: 'GetOrdersGrid',
data: { ShipmentNumber: shipment },
success: function (shipment) {
paintOrders(`shipment`);
the function gets a number of div and needs to put the TEXT into the div
<div id="11626">TEXT</div>
<br>
<div id="12109">TEXT</div>
ERROR: ("#" + items).append is not a function [Break On This Error] ('#' + items).append($(container));
WHEN i use the sollar sign $('#' + items).append($(container));
ERROR uncaught exception: Syntax error, unrecognized expression: #[object Object]
WHEN i use without the #
$(items).append(container); or $(items).append($(container));
(this[0].ownerDocument || this[0]).createDocumentFragment is not a function
[Break On This Error] var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(),
Share
Improve this question
edited Nov 25, 2011 at 18:46
Kristina88
asked Nov 25, 2011 at 18:00
Kristina88Kristina88
571 silver badge7 bronze badges
4 Answers
Reset to default 5You're missing a $
Change
('#' + items).append($(container));
to
$('#' + items).append($(container));
Presuming, of course, that you have an element with id
set to whatever items
resolves to.
you're missing the $
$('#' + items).append($(container));
Try this $('#' + items).append($(container));
instead of (items).append($(container));
// items is unique number
function paintOrders(items) {
var container = '<div>';
$.each(items, function () {
container += 'TEXT' + '<br/>';
});
container += '</div>';
$(items).append($(container));
}
Try this code:
function paintOrders(items) {
var lastIndex = items.length - 1;
$.each(items, function (index, item) {
if (index == lastIndex)
$('#'+item).append('<div>'+'TEXT'+'</div>');
else
$('#'+item).append('<div>'+'TEXT'+'</div>'+'<br/>');
});
}
Maybe this code is not exectly what you need but you might find some leads from it.
本文标签: javascript(quotquotitems)append is not a functionStack Overflow
版权声明:本文标题:javascript - ("#" + items).append is not a function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744849323a2628400.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论