[英]Need help adding code into JS using another JS
I have a script tag in a web-page which contains a function updatevalues(value) .我在包含 function updatevalues(value)的网页中有一个脚本标签。 I need to add code into that function using another javascript tag.
我需要使用另一个 javascript 标记将代码添加到 function 中。
I am able to similarly write into other html elements by using getemementbyid.innerHTML...我可以通过使用 getemementbyid.innerHTML 类似地写入其他 html 元素...
How can i add code inside a JS function using another JS tag?如何使用另一个 JS 标签在 JS function 中添加代码?
My current code is:我目前的代码是:
<script>
function updatevalues(value){
var a=1;
}
</script>
I want to make it like this:我想让它像这样:
<script>
function updatevalues(value){
var a=1;
var b=2;
}
</script>
You don't need to edit the previous <script>
.您不需要编辑以前的
<script>
。 Literally just write this in a new <script>
:从字面上看,只需将其写在一个新的
<script>
中:
function updatevalues(value) {
var a=1;
var b=2;
}
And it will override the definition of the same function in the previous script.它将覆盖前面脚本中相同 function 的定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.