The easiest thing to do would be to add a 'return false;' directly after setting the background colour.
The full code would look like this:
<body>
<div id="super">
<div id="parent">
<form>
<input type="text" id="in">
</form>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$("form").submit(function() {
$("#parent").css("background","yellow");
return false;
});
});
</script>
</body>
UPDATE: This is how you would do it with e.preventDefault() as recommended in Richard's comment:
(note that you must add a single named parameter (in this case I used 'e') to the submit event handler which passes through the actual Event as an object).
<body>
<div id="super">
<div id="parent">
<form>
<input type="text" id="in">
</form>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$("form").submit(function(e) {
$("#parent").css("background","yellow");
e.preventDefault();
});
});
</script>
</body>
I would recommend going with the e.preventDefault() route for future code consistencies sake.
click.