如何將變量傳遞給匿名函數。我想將幾個變量傳遞給一個匿名函數,基於這個函數,它會創建一個新的字符串。 在這段代碼中,我想傳遞url,時間戳,id和計劃。如何在jQuery中的匿名函數中獲取變量?
<script>
jQuery(document).ready(function() {
console.log("check")
var newUrl=url+'?id='+id+'×tamp='+timestamp+'&plan='+plan;
console.log(newUrl);
createStoryJS({
type: 'timeline',
width: '1250',
height: '240',
source: newUrl,
embed_id: 'my-timeline'
});
});
</script>
哪裏是匿名函數? – Satpal
@Satpal抱歉,我是JS新手。我試圖在函數()中傳遞一些變量。 –
好吧,從哪裏,你是如何通過它 – Satpal