JavaScript国旗变换效果代码
程序员文章站
2023-08-31 14:17:32
1.页面的html代码如下:
1.页面的html代码如下:
<img id="flag" src="flags/cn_flag[1].gif" alt="" />
<select name="country" accesskey="c" id="country" onchange="change_flag(this);" runat="server" o>
<option value="ar">argentina</option>
<option value="am">armenia</option>
<option value="au">australia</option>
<option value="at">austria</option>
<option value="ba">bosnia and herzegovina</option>
<option value="bd">bangladesh</option>
<option value="by">belarus</option>
<option value="be">belgium</option>
<option value="bg">bulgaria</option>
<option value="bo">bolivia</option>
<option value="bw">botswana</option>
<option value="br">brazil</option>
<option value="bg">bulgaria</option>
<option value="ca">canada</option>
<option value="cl">chile</option>
<option value="cn" selected="selected">china</option>
<option value="co">colombia</option>
<option value="cr">costa rica</option>
<option value="hr">croatia</option>
<option value="cu">cuba</option>
<option value="cz">czech republic</option>
<option value="dk">denmark</option>
<option value="ec">ecuador</option>
<option value="eg">egypt</option>
<option value="ee">estonia</option>
<option value="fi">finland</option>
<option value="fr">france</option>
<option value="de">germany</option>
<option value="gb">great britain</option>
<option value="uk">united kingdom</option>
<option value="ge">georgia</option>
<option value="gr">greece</option>
<option value="hk">hong kong</option>
<option value="hu">hungary</option>
<option value="is">iceland</option>
<option value="in">india</option>
<option value="id">indonesia</option>
<option value="ie">ireland</option>
<option value="il">israel</option>
<option value="it">italy</option>
<option value="jp">japan</option>
<option value="jo">jordan</option>
<option value="kz">kazakhstan</option>
<option value="kg">kyrgyzstan</option>
<option value="la">laos</option>
<option value="lv">latvia</option>
<option value="lt">lithuania</option>
<option value="lu">luxembourg</option>
<option value="ma">morocco</option>
<option value="my">malaysia</option>
<option value="mt">malta</option>
<option value="mx">mexico</option>
<option value="ng">nigeria</option>
<option value="nl">netherlands</option>
<option value="nz">new zealand</option>
<option value="no">norway</option>
<option value="om">oman</option>
<option value="pa">panama</option>
<option value="pk">pakistan</option>
<option value="pe">peru</option>
<option value="ph">philippines</option>
<option value="pl">poland</option>
<option value="pt">portugal</option>
<option value="qa">qatar</option>
<option value="ro">romania</option>
<option value="ru">russia</option>
<option value="sa">saudi arabia</option>
<option value="sn">senegal</option>
<option value="sg">singapore</option>
<option value="sk">slovakia</option>
<option value="si">slovenia</option>
<option value="za">south africa</option>
<option value="kr">south korea</option>
<option value="es">spain</option>
<option value="lk">sri lanka</option>
<option value="sr">suriname</option>
<option value="se">sweden</option>
<option value="ch">switzerland</option>
<option value="tw">*</option>
<option value="th">thailand</option>
<option value="tn">tunisia</option>
<option value="tr">turkey</option>
<option value="ua">ukraine</option>
<option value="uk">united kingdom</option>
<option value="us">united states</option>
<option value="uy">uruguay</option>
<option value="ve">venezuela</option>
<option value="vn">vietnam</option>
<option value="vu">vanuatu</option>
<option value="zm">zambia</option>
</select>2.change_flag函数 <script>
function change_flag( object ){
var img = document.getelementbyid("flag");
if( img ){
img.src = "flags/" + object.value +"_flag[1].gif";
}
}
</script>
在线演示http://img.jb51.net/online/guoqi/flags.html
打包下载
<img id="flag" src="flags/cn_flag[1].gif" alt="" />
<select name="country" accesskey="c" id="country" onchange="change_flag(this);" runat="server" o>
<option value="ar">argentina</option>
<option value="am">armenia</option>
<option value="au">australia</option>
<option value="at">austria</option>
<option value="ba">bosnia and herzegovina</option>
<option value="bd">bangladesh</option>
<option value="by">belarus</option>
<option value="be">belgium</option>
<option value="bg">bulgaria</option>
<option value="bo">bolivia</option>
<option value="bw">botswana</option>
<option value="br">brazil</option>
<option value="bg">bulgaria</option>
<option value="ca">canada</option>
<option value="cl">chile</option>
<option value="cn" selected="selected">china</option>
<option value="co">colombia</option>
<option value="cr">costa rica</option>
<option value="hr">croatia</option>
<option value="cu">cuba</option>
<option value="cz">czech republic</option>
<option value="dk">denmark</option>
<option value="ec">ecuador</option>
<option value="eg">egypt</option>
<option value="ee">estonia</option>
<option value="fi">finland</option>
<option value="fr">france</option>
<option value="de">germany</option>
<option value="gb">great britain</option>
<option value="uk">united kingdom</option>
<option value="ge">georgia</option>
<option value="gr">greece</option>
<option value="hk">hong kong</option>
<option value="hu">hungary</option>
<option value="is">iceland</option>
<option value="in">india</option>
<option value="id">indonesia</option>
<option value="ie">ireland</option>
<option value="il">israel</option>
<option value="it">italy</option>
<option value="jp">japan</option>
<option value="jo">jordan</option>
<option value="kz">kazakhstan</option>
<option value="kg">kyrgyzstan</option>
<option value="la">laos</option>
<option value="lv">latvia</option>
<option value="lt">lithuania</option>
<option value="lu">luxembourg</option>
<option value="ma">morocco</option>
<option value="my">malaysia</option>
<option value="mt">malta</option>
<option value="mx">mexico</option>
<option value="ng">nigeria</option>
<option value="nl">netherlands</option>
<option value="nz">new zealand</option>
<option value="no">norway</option>
<option value="om">oman</option>
<option value="pa">panama</option>
<option value="pk">pakistan</option>
<option value="pe">peru</option>
<option value="ph">philippines</option>
<option value="pl">poland</option>
<option value="pt">portugal</option>
<option value="qa">qatar</option>
<option value="ro">romania</option>
<option value="ru">russia</option>
<option value="sa">saudi arabia</option>
<option value="sn">senegal</option>
<option value="sg">singapore</option>
<option value="sk">slovakia</option>
<option value="si">slovenia</option>
<option value="za">south africa</option>
<option value="kr">south korea</option>
<option value="es">spain</option>
<option value="lk">sri lanka</option>
<option value="sr">suriname</option>
<option value="se">sweden</option>
<option value="ch">switzerland</option>
<option value="tw">*</option>
<option value="th">thailand</option>
<option value="tn">tunisia</option>
<option value="tr">turkey</option>
<option value="ua">ukraine</option>
<option value="uk">united kingdom</option>
<option value="us">united states</option>
<option value="uy">uruguay</option>
<option value="ve">venezuela</option>
<option value="vn">vietnam</option>
<option value="vu">vanuatu</option>
<option value="zm">zambia</option>
</select>2.change_flag函数 <script>
function change_flag( object ){
var img = document.getelementbyid("flag");
if( img ){
img.src = "flags/" + object.value +"_flag[1].gif";
}
}
</script>
在线演示http://img.jb51.net/online/guoqi/flags.html
打包下载
上一篇: 阿诺的手机壳