When you select using something like $("stuff"), jquery looks for a <stuff>
tag, which oviously doesnt exist. To search by class, you use $(".stuff"),
and to search by ID you use $("#stuff").

In your case, you wanted to search for a select by name, so you would do
$("[EMAIL PROTECTED]'stuff']")

Or, like you just did, using IDs makes the code alot quicker.

On 6/9/07, Guoliang Cao <[EMAIL PROTECTED]> wrote:


Thank you for your help. But your code doesn't work here. I changed to
use id and suddenly everything worked. Here is the new code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<html debug="true">
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>Test Page</title>
<script language="JavaScript" type="text/javascript" src="/
jsgameviewer/js/jquery.js"></script>
<script language="JavaScript">
function openGame(){
        var option = $("#games [EMAIL PROTECTED]");
        alert(option.text());
}
</script>
</head>
<body>
Select one:
<select id="games">
        <option selected="true">games/test1.sgf</option>
        <option>games/test2.sgf</option>
        <option>games/test4.sgf</option>
</select>

<script language="JavaScript" type="text/javascript">
openGame();
$("#games").change(openGame);
</script>
</body>
</html>


Reply via email to