How can I transform the following jquery to javascript?
iElement.children('li')
.css({ "background": "#DDD" })
.slice(0, 1)
.css({ "background": c.col });
IElement.children('li')
returns the following:
[li.point, li.point, li.point, li.point, li.point]
where iElement
is a ul
.
The problem comes in with the slice()
. iElement is an array of objects but I get an error saying that whatever.slice()
is not a function
I am trying to write a password strength directive for my angularjs app.
You get this Exception because you were trying to call an
Array
method (.slice()
) over anodeList
which is not anarray
.You have to treat this
nodeList
as anarray
, you can :.slice()
.Array.prototype.slice.call(IElement.children('li'));