javascript - Adding get() to line causes "is not a function" error -


This is the beginning of an inventory system on which I am working. Basically, it takes an array with objects and quantities in a compressed form and outputs items of items in an item div.

No errors occur in running below:

  $ ('item_amount') HTML (archive [ITEMNAME] .a).   

Adding the get () method after liking the selector:

  $ ('item_amount'). Get (i) .html (archive [ITEMNAME] .a);   

"$ (". Item_amount ") produces. Get (i) .html is not a function."

This is what is altering the line:

  & lt; Div class = "item" & gt; & Lt; Img src = "" class = "item_image" /> & Lt; Div class = "item_amount" & gt; & Lt; / Div & gt; & Lt; / Div & gt;   

The error that is causing the error is located in a loop that has riveting through all the keys in the array. Then itemizes the item quantity from the array in the item_mount div, depending on the index stored in the item "Quantity". Creates an object for each item in the array for the loop and puts it in the collection object.

Full code below:

  & lt; Body & gt; & Lt; Div class = "item" & gt; & Lt; Img src = "" class = "item_image" /> & Lt; Div class = "item_amount" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "item" & gt; & Lt; Img src = "" class = "item_image" /> & Lt; Div class = "item_amount" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "item" & gt; & Lt; Img src = "" class = "item_image" /> & Lt; Div class = "item_amount" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Script type = "text / javascript" & gt; Var Collection = New Object (); Function MacTime (ItemName, ID, AMO) {Collection [ItemName] = New Item (ID, AMO); } Function item (id, amo) {this.id = id; This.amo = amo; } Inv inventoryCom = "368.9,366.15,384.32"; // Comprehensive inventory var inventoryRR = inventory com. Split (','); (Var item name = 'item' + (i + 1); // for each item var itemArr = inventoryArr [i] .split ('. '), MacTyme ​​(item name, itemair [0], itemar [1]) (' item_amount '). $ Mill (i) .html (archive [ITEMNAME] .a);} & lt; / Script & gt; & lt; / body & gt;    

is not .html method - that is what JS engine wants to tell you.

You need to use it instead like

  $ ('. Item_amount'). Eq (i) .html (archive [itemName] .a);   

or

  $ ('. Item_amount: eq (' + i + ')') .html (archive [itemName] .a);    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -