简体   繁体   English

在现有的javascript函数中插入一些jquery代码

[英]insert some jquery code in existing javascript function

Working with some code, i had modified some code where i am doing some manipulation of selections, but i need to insert some code after the specific javascript code: 使用一些代码,我修改了一些代码,在这些代码中我对选择进行了一些操作,但是我需要在特定的javascript代码之后插入一些代码:

The code is 该代码是

product.options[product.options.length] = newoption;
    switch(cSelected) {

i want it to be: 我希望它是:

product.options[product.options.length] = newoption;
        var x = 0;
        while(x < cSelected.length){
            switch(cSelected[x]) {

now the identification line is: 现在的识别行是:

product.options[product.options.length] = newoption;

i am trying to use insertAfter but lost how to add this 我试图使用insertAfter但丢失了如何添加此

same case is the ending of the function 同样的情况是函数的结尾

break;

    }

}

need to be like this: 需要像这样:

break;

            }
            x++;
        }

    }

If you have access to the source file you should make the changes directly. 如果您有权访问源文件,则应直接进行更改。 If not you can replace the reference with your own function declaration so that any subsequent calls to the function will execute your function. 如果不是,则可以用自己的函数声明替换引用,以便对该函数的任何后续调用都将执行您的函数。 Note that any bounded references to the original function will not be overridden and will still call the original function. 请注意,对原始函数的任何有界引用都不会被覆盖,并且仍会调用原始函数。

//original
function llama() {
    product.options[product.options.length] = newoption;
    switch(cSelected) {}
}
//your new function
llama = function(){
product.options[product.options.length] = newoption;
var x = 0;
while(x < cSelected.length){
    switch(cSelected[x]) {}
x++;
}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM