0
我有兩個腳本。一個獲得複選框值,另一個將追加我的<a>
標記。兩者都單獨工作,但我需要將'str'的值放在我的url追加腳本中,而我似乎無法使其工作。獲取URL的追加框值附加
我獲取複選框的樣子:
<script>
var checked, checkedValues = new Array();
$(document).on('change', 'input[type=checkbox]', function(e) {
checked = $('input[type=checkbox]:checked');
checkedValues = checked.map(function(i) { return $(this).val() }).get();
$('.aaa').html(checked.length + ' are checked');
if (checked.length) {
var str = checkedValues.join();
});
</script>
我的第二個腳本追加的URL是這樣的:
<script>
$('.nextquestion').attr('href', function() {
this.href = this.href + '&answers=+str+';
});
</script>
我試圖把 'STR' 的價值在我的網址。有人可以幫忙嗎?
meaby你應該做'$('。nextquestion')。click(function(){/ * compute newComputedUrl */window.location = newC omputedUrl;});'而不是'$('。nextquestion')。attr('href',...'。 –