社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  David Japan  »  全部回复
回复总数  1
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)
})