简体   繁体   中英

Using a jquery variable in a href attr

I am trying to take the jQuery variables and insert them in to the href attribute.

Here is the jQuery

$(".id_container").click(function() {
                        var item_id = $(this).find(".item").val();
                        var std_id = $(this).find(".std").val();
                        var cre_id = $(this).find(".cre").val();
                         $(location).attr('href',"link.php?item=''+item+''&stid=''+std+''&cre=''+cre+''");
                    });

如果您有两个单引号,则应该有一个双引号,并且最后不需要多余的引号:

$(location).attr('href',"link.php?item="+item+"&stid="+std+"&cre="+cre);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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