我有下面這個腳本,假設從輸入字段獲取值,然後將它們添加到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