Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- onLoad problem


greencode - 8:28 am on Oct 25, 2012 (gmt 0)


I found this script on JS Fiddle and it uses onLoad but when I create the HTML myself I can't get it to function at all. I'm sure this is just a basic issue!

Any help would be greatly appreciated…


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title></title>
<style type="text/css">
.Default {
background-color:white
}

.Black {
background-color:black;
color:white
}

.Blue {
background-color:Cyan;
}

.Brown {
background-color:brown;
}

.Green {
background-color:green;
}

.Gray {
background-color:gray;
}

.Lime {
background-color:lime;
}

.Orange {
background-color:orange;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
var selectedScheme = 'Default';

$('#color_scheme').change(function(){
$('span').removeClass(selectedScheme).addClass($(this).val());
selectedScheme = $(this).val();
});
</script>
</head>
<body>
<select name="color_scheme" id="color_scheme">
<option selected="selected">Default</option>
<option>Black</option>
<option>Blue</option>
<option>Brown</option>
<option>Green</option>
<option>Gray</option>
<option>Lime</option>
<option>Orange</option>
</select>
<span class="Default">Some text here</span>
</body>
</html>


Thread source:: http://www.webmasterworld.com/javascript/4512151.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com