Home > front end >  Why javascript call. Js file does not have effect?
Why javascript call. Js file does not have effect?

Time:09-16

this is to generate the accumulation and hasn't been drawing



<meta charset="utf-8"/& gt;

<style type="text/CSS" & gt;
Div {
text-align: center; Margin: 20 px auto; The line - height: 1.5;
Border: 18 px groove # 66 ff66; Width: 560 px; Height: 260 px; font-weight: bold;
}
The form {
Margin: 20 px auto; Padding: 5 px;

}

</style>
<script SRC="https://bbs.csdn.net/topics/sum.js" type="text/javascript" charset="utf-8" & gt; </script>
The function $(id) {return document. The getElementById (id); }
The function show () {
Var n11=parseFloat ($(" start_num "). The value).//get the data and into a floating point number
Var n22=parseFloat ($(" end_num "). The value).
If (n11 & gt; 0 & & N22 & gt; 0)//input data must be greater than 0
{
If (n11 & gt;=n22)
{alert (" starting number must be less than end, heavy lose, please!" );
$(" start_num "). The value="";//to empty text field
$(" end_num "). The value="";//to empty text field
$(" start_num "). The focus ();//text field gains focus
}
The else {//backfill accumulation and text box
$(" sum "). value=https://bbs.csdn.net/topics/sum (n11, n22);
}
}
The else {
Alert (" please input data!" );
$(" start_num "). The focus ();//text field gains focus
}
}

</script>



<body>







The following is the sum. Js
The function sum (n1, and n2) {
For (var I=n1, sum1=0; I<=n2; I++)
{sum1=sum1 + I; }//execution accumulative
Return sum1;//return the results
}

Mentally I learned this semester, I also don't know did call right, because requirements is the need to call. Js file, so can't directly write the script tags in a turn

CodePudding user response:

Your js jq but you seem to not quote jq

CodePudding user response:

Put js code in HTML to below

CodePudding user response:

Jquery didn't see you quoted, js are written in the last, have loading sequence effect, and have a look at the stamp pad quote me what's wrong

CodePudding user response:

 
The function of $(id) {
Return the document. The getElementById (id);
}


Someone wrote a $(" XXX ") is the jquery!!!!!! Code didn't answer,

CodePudding user response:

refer to the second floor jio can reply:
put the js code to HTML below
in here also can't hey

CodePudding user response:

reference sha worm agent reply: 3/f
jquery didn't see you quoted, js are written in the last, the effect of loading sequence has, what is wrong and have a look at the stamp pad quote me no
background also shows no mistakes

CodePudding user response:

I just copy your code after running for a moment, also use the ie browser, completely no problem!!!!!!!!!! I use Google is also no problem



But when ie above entered an option, you won't get that thing is disabled.

CodePudding user response:

Your js files and HTML files in the same directory? I tried to run

CodePudding user response:

 




<meta charset="utf-8"/& gt;

<style type="text/CSS" & gt;
Div {
text-align: center;
Margin: 20 px auto;
The line - height: 1.5;
Border: 18 px groove # 66 ff66;
Width: 560 px;
Height: 260 px;
font-weight: bold;
}

The form {
Margin: 20 px auto;
Padding: 5 px;

}
</style>





<body>



  • Related