$.getScript("func2.js", function() {
$(".teste1").text("1");
$(".teste2").text("2");
});
<div class="teste1" style="color: red"><div>
<div class="teste2"><div>
Why did he only enter once?
$.getScript("func2.js", function() {
$(".teste1").text("1");
$(".teste2").text("2");
});
<div class="teste1" style="color: red"><div>
<div class="teste2"><div>
Why did he only enter once?
Because you have an error in your code, notice that it has a comma, remove it and it will solve.
Remove this comma at the end:
$(".teste1").text("1"),
To:
$(".teste1").text("1");
You have 3 errors in your code:
/
{
is missing at function opening ;
and not ,
to separate lines
$(document).ready(function(){
$(".teste1").text("1");
$(".teste2").text("2");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="teste1" style="color: red"></div>
<div class="teste2"></div>
I put your code in jsfiddle
, clear removing the name of the script and it works, only correcting the tags that are wrong:
<div class="teste1" style="color: red"><div>
Should be:
<div class="teste1" style="color: red"></div>
E
<div class="teste2"><div>
Should be
<div class="teste2"></div>
That is, the div
tags are not being closed