php1306
02-24-2012, 04:55 PM
Hi all,
I'm trying to link a java script file to a html file but it's not working.
Any ideas?
HTML:
<head><script type="text/javascript" src="newjavascript.js"></script></head>
<body> <div id="myRadioGroup">
2 Cars<input type="radio" name="cars" checked="checked" value="twoCarDiv" />
3 Cars<input type="radio" name="cars" value="threeCarDiv" />
<div id="twoCarDiv" class="desc">
2 Cars Selected
</div>
<div id="threeCarDiv" class="desc">
3 Cars
</div>
</div>
</div></body>
JS:
$(document).ready(function(){
$("input[name='cars']").click(function() {
var test = $(this).val();
$(".desc").hide();
$("#"+test).show();
});
});
I'm trying to link a java script file to a html file but it's not working.
Any ideas?
HTML:
<head><script type="text/javascript" src="newjavascript.js"></script></head>
<body> <div id="myRadioGroup">
2 Cars<input type="radio" name="cars" checked="checked" value="twoCarDiv" />
3 Cars<input type="radio" name="cars" value="threeCarDiv" />
<div id="twoCarDiv" class="desc">
2 Cars Selected
</div>
<div id="threeCarDiv" class="desc">
3 Cars
</div>
</div>
</div></body>
JS:
$(document).ready(function(){
$("input[name='cars']").click(function() {
var test = $(this).val();
$(".desc").hide();
$("#"+test).show();
});
});