index.html我的页面中有两个 JavaScript 变量。我想在 control.js 中使用这两个变量。
index.html有一些像下面这样的 jQuery 脚本
<script>
$(document).ready(function() {
// load select code from country.html
$('#selectCourse_country').load('country.html select', function() {
// when country is selected
$('#selectCourse_country select').change(function() {
// get id
var countryId = $(this).children('option:selected').val();
// load select code from state.html by id
$('#selectCourse_state').load('state.html #'+countryId,function(){
$('#selectCourse_state select').change(function(){
var stateId = $(this).children('option:selected').val();
//alert(stateId);
});
});
});
});
});
</script>
我想使用变量的值countryId和stateIdin control.js。我怎样才能将它们从index.htmlto传递给control.js.