简体   繁体   中英

Javascript passing variable to Jquery

<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>

but i want to move it to the page. im unsure how i send the variable "txt" to my jquery function

Make the function have a return statement.

function DoThings() {
   var txt = txtbox.value;
   txt = /* passed info from code behind */
   return txt; //return it.
}

$(function() { 
    var Tags=[DoThings()]; $("#txtbox2").autocomplete({source: Tags});});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM