我有一个触发函数来更改值的html表单,参考:http: //jsfiddle.net/ZvuMh/3/
如何avalue
在另一个函数中动态使用?
HTML:
<select id="sort_post_date">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
<option value="d">d</option>
<option value="e">e</option>
<option value="f">f</option>
</select>
变值函数:
var avalue='';
function getSelectData(id) {
// set value to be the current selected value
avalue = jQuery(id+" option:selected").val();
// change value whenever the box changes
jQuery(id).change(function () {
avalue = jQuery(id+" option:selected").val();
console.log("I see a change! -> "+avalue);
});
console.log(avalue);
return avalue;
}
var d = getSelectData("#sort_post_date");
console.log(d);
avalue
当函数 getSelectData 将其更改为另一个字母时要继承的另一个函数:
function somefunction(){
var test = "foo"+avalue;
}