如果它們對鏈接不爲空,我想追加這些值。它不允許if在字符串中,所以我應該怎麼做呢?如果不爲空,則追加到url
var age = $('#age').val();
var fn = $('#fn').val();
var ln = $('#ln').val();
var city = $('#city').val();
var country = $('#country').val();
var link = "https://mysre.com/articles/index.php?title=man-sets-biggest-pizza-record" if(age !=null){ "&age=" + age + } "&fn=" + fn + "&ln=" + ln + "&city=" + city + "&country=" + country;
謝謝你的回答。我已經用這個選項去了 – quizzaman
很酷。很高興它解決了。 – Snowmonkey