私信  •  关注

David Japan

David Japan 最近创建的主题
David Japan 最近回复了
4 年前
回复了 David Japan 创建的主题 » 可以从Jquery中的接收值使用“variables”吗?

是的,你可以!我建议使用对象类型。所以试试下面的

$(document).on('change','select#country',function(){
var CodeList = {
  Netherlands : "Code: NL. A currency in Netherlands is Euro (EUR)",
  Poland      : "Code: PL. A currency in Poland is Polish Zloty (PLN)"
}
var xd = $(this).find('option:selected').text()
alert(CodeList[xd]) //use a var from received text (which equal to var)
})