请看代码和注释:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MyJquery.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript" src="jquery-1.4.4.js"></script>
<script type="text/javascript">
$(function()
{
var str = "";
var str1 = $("select[name='Asia'] :selected").text();//为什么在“select”后面必须紧跟着一个空格?
var str2 = $("select[name='Europe'] :selected").text();
$("select[name='Asia']").change(function()
{
str1 = $("select[name='Asia'] :selected").text();
str = str1 + " and " + str2;
$("div[id='tour shedule']").html("The tour schedule you choose is: <font color='red'><b>"
+ str + "</b></font>");
});
$("select[name='Europe']").change(function()
{
str2 = $("select[name='Europe'] :selected").text();
str = str1 + " and " + str2;
$("div[id='tour shedule']").html("The tour schedule you choose is: <font color='red'><b>"
+ str + "</b></font>");
});
});
</script>
</head>
<body>
<h2><font color="red"><b>Please choose your tour schedule:</b></font></h2>
<table border="0" align="left" width="25%">
<tr>
<td>
<div>
<b>Asia countries(districts)</b><br>
<select name="Asia">
<option>Hong Kong</option>
<option>Macao</option>
<option>Taipei</option>
<option>Singapo</option>
<option>Malaysia</option>
</select>
</div>
</td>
<td>
<div>
<b>Europe countries</b><br>
<select name="Europe">
<option>America</option>
<option>Germany</option>
<option>France</option>
<option>Italy</option>
<option>England</option>
</select>
</div>
</td>
</tr>
</table>
<span>
<image src="HongKong.png" width="500" height="300"></image>
</span>
<div id="tour shedule"></div>
</body>
</html>
|
|