Let’s take a look at the phenomenon first:
$(".main ").append("haha");
$(".main").append("xixi");
alert($(".main").html());
Result: hahaxixi
Everything is fine
Change it
$(".main").append("
This is span");
$(" .main").append("
");
alert($(".main").html());
Result:
This is span
This is not normal, as long as there are two This exception will occur when append() html code is used. I don’t know why. I searched and found no relevant information. The temporary solution is to avoid appending html code in this way.