如何将变量传递给匿名函数。我想将几个变量传递给一个匿名函数,基于这个函数,它会创建一个新的字符串。 在这段代码中,我想传递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