Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

var eaclink = $('a.topLink'),
eacwrap = $('div.pan_inner');

for(var i = 0; i < eaclink.length; i++) {
    eacwrap[i].wrap('<div class="panel panel-default"><div id="collapse1" class="panel-collapse collapse in"><div class="panel-body"></div></div></div>');
    eaclink[i].attr("data-toggle", "collapse").attr("data-parent", "#accordion").attr("href", "collapse1");
}

How do I know whats the undefined function?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
158 views
Welcome To Ask or Share your Answers For Others

1 Answer

Both wrap and attr will be not a function because you're operating on a DOM element instead of a jQuery object.

Use .eq(i) instead of [i] to fetch the element wrapped with a jQuery object.

Example:

eacwrap.eq(1).wrap()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...