jQuery - 克隆和操作变量

时间:2016-06-07 21:44:17

标签: jquery wordpress variables clone extend

我正在尝试对使用jQuery进行一些变量操作的旧Wordpress插件进行故障排除。原始代码如下:

            var p = $(this).parents('.postbox'); /*wp*/
            var the_name = $(this).attr('class').match(/docopy-([a-zA-Z0-9_-]*)/i)[1];
            var the_group = $('.wpa_group-'+ the_name +':first.tocopy', p);
            var the_clone = the_group.clone().removeClass('tocopy last');

我不相信克隆功能正常工作。我的测试代码如下:

            var the_name = "name";
            console.log(the_name);
            var the_group = $('.wpa_group-'+ the_name +':first.tocopy');
            console.log(the_group);             
            var the_clone = the_group.clone().removeClass('tocopy last');
            console.log(the_clone);
            var the_clone_test = the_group.clone();
            console.log(the_clone_test);

原始克隆功能(使用removeClass)或我的克隆测试都不会将任何数据返回到控制台。我错过了一些非常简单的东西吗?自从网站构建以来,我不相信代码已被修改,但WordPress或jQuery版本可能在此期间发生了变化。

0 个答案:

没有答案