我有下面这个脚本,假设从输入字段获取值,然后将它们添加到href链接中。但我一直在控制台收到此错误:JQuery错误:未捕获错误:语法错误,无法识别的表达式
Uncaught Error: Syntax error, unrecognized expression: ?add-to-cart=7690&variation_id=8498&attribute_pa_color=gold
下面是脚本:
jQuery(document).on("click", ".variations_form.cart .variation_buttons_wrapper a", function(){
// Get all the values needed for the URL
var add_to_cart = jQuery(this).parent().parent().parent().parent().parent().parent().find('input[name="add-to-cart"]').val();
var variation_id = jQuery(this).parent().parent().parent().parent().parent().parent().find('input[name="variation_id"]').val();
var pa_color = jQuery(this).attr("id");
setTimeout(function(){
// Craft the URL
var link = jQuery("?add-to-cart=" + add_to_cart + "&variation_id=" + variation_id + "&attribute_pa_color=" + pa_color);
alert(link);
}, 500);
});
任何想法?
谢谢你的工作。 – mysticalghoul
我会但是显然我必须再等5分钟。 – mysticalghoul