Conflict between .show() and .append() in JQuery
I have a div with id="poidiv" whose display is 'none' initially. Now I want to l开发者_开发技巧oad it more than once with a loop (the max value of the loop is dynamic). I tried it with JQuery .append().clone().
Here is the example code--
$(document).ready(function(){
$("#levelnext").click(function(){
for(i=1; i<=level; i++){
$("#leveldiv").append($("#poidiv").clone().removeAttr("id"));
}
});
});
But because the display of "poidiv" was initially 'none', it does not appear with this piece of code. Now if I want to show it with .show() before the loop starts, the loop is not working in a good manner. What might be a good solution in this situation?
You can .show() in the chain, like this:
$("#leveldiv").append($("#poidiv").clone().removeAttr("id").show());
加载中,请稍侯......
精彩评论