I am using the following code for
1) Display the changed content in DIV container so if someone types in textbox it should simultaneously display the typed content
2) on selection of fonts, font should be applied to that content
But its not working not sure what wrong i am doing ?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Change Contents</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
$("#fs").change(function() {
alert($(this).val());
$('.changeMe').css("font-family", $(this).val());
});
$("#size").change(function() {
$('.changeMe').css("font-size", $(this).val() + "px");
});
</script>
</head>
<body>
<form id="myform">
<button>erase</button>
<select id="fs">
<option value="Arial">Arial</option>
<option value="Verdana ">Verdana </option>
<option value="Impact">Impact </option>
<option value="Comic Sans MS">Comic Sans MS</option>
</select>
<select id="size">
<option value="7">7</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
</select>
</form>
<br/>
<textarea class="changeMe">Text into textarea</textarea>
<div id="container" class="changeMe">
<div id="float">
<p>
Text into container
</p>
</div>
</div>
</body>
</html>
Pleae initialize your handler in the jQuery ready() clause.
Your code may look like this:
…
Other changes :
If you want only the div to be changed, simply replace
$('.changeMe')by$('#float')in the two last handlers.