初心者で、私は何かを取り除こうとしていて、つかれてしまいました。私は "fc_cart_foot_tax_tbd"のIDを持つ表の行を選択しようとしていて、誰かが "customer_state_name"のクラスを持つ入力フィールドにイリノイ州以外の州を入力した場合、 "selected"のクラスを追加しようとしています。ここで私のHTMLは動作しません。jQuery - 入力が値と一致しない場合に別のtrを選択する方法
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Basic</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
//Show the tax info if the shipping state is not Illinois
$("#customer_state_name").each(function()
{
if (!$(this).html() == 'Illinois')
{
$("#fc_cart_foot_tax_tbd").addClass("selected");
}
});
});
</script>
</head>
<body>
<form action="#">
<input name="state" id="customer_state_name" value="" />
</form>
<table>
<tr id="fc_cart_foot_tax_tbd">
<td>Content here!</td>
</tr>
</table>
</body>
</html>
私はデモを掲示するために、[JSフィドル](http://jsfiddle.net/)を提案、または[JSビン](http://jsbin.com/)もいいですか?また、テーブル行を「選択」することで、どういう意味ですか? –
おはようございます...ありがとうございます。私は明らかにするために投稿を更新しました。私が意図したのは、上記のIDを持つ行にクラスを追加することでした。希望が役立ちます。 – flinx777