私はこのコードを持っていますが、ラジオボタンをクリックしても画像の src が変わらないのはなぜですか?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Toggle Images using RadioButtons</title>
<script type="text/javascript"
src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
$("input:radio[name=style]").change(function() {
if (this.value == "tuxedo"){
var style = 'tuxedo';
} else {
var style = 'classic' ;
}
});
$("input:radio[name=breast]").change(function() {
if (this.value == "double"){
var breast = 'double';
} else {
var breast = 'single' ;
}
});
$("input:radio[name=buttons]").change(function() {
if (this.value == "4"){
var buttons = '4';
} else if (this.value == "3"){
var buttons = '3';
} else if (this.value == "2"){
var buttons = '2';
} else {
var buttons = '1' ;
}
});
$("#imgDef").attr(
'src', 'http://127.0.0.1/2/suits/'+ style +'/'+ breast +'/'+ buttons +'.jpg'
);
});
</script>
</head>
<body>
Style:<br />
<label><input name="style" type="radio" value="classic" />Classic</label><br />
<label><input name="style" type="radio" value="tuxedo" />Tuxedo</label><br />
<br /><br />
Breast:<br />
<label><input name="breast" type="radio" value="single" />Single</label><br />
<label><input name="breast" type="radio" value="double" />Double</label><br />
Buttons:<br />
<label><input name="buttons" type="radio" value="1" />1</label><br />
<label><input name="buttons" type="radio" value="2" />2</label><br />
<label><input name="buttons" type="radio" value="3" />3</label><br />
<label><input name="buttons" type="radio" value="4" />4</label><br />
<img id="imgDef" src="http://127.0.0.1/2/suits/classic/single/1.jpg"/>
</body>
</html>