<script type="text/javascript">
function DoThings()
{
var txt = txtbox.value;
txt = /* passed info from code behind */
}
$(function() { var Tags=[ txt ]; $( "txtbox2").autocomplete({source: Tags});});
</script>
但我想将其移至页面。我不确定如何将变量“txt”发送到我的jquery函数
答案 0 :(得分:1)
使函数具有return语句。
function DoThings() {
var txt = txtbox.value;
txt = /* passed info from code behind */
return txt; //return it.
}
$(function() {
var Tags=[DoThings()]; $("#txtbox2").autocomplete({source: Tags});});