// `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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744849323a4597032.html
评论列表(0条)