When a user clicks on the textbox, the font in the textbox should change color, but for some reason it does not.
I have the following code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$(".textbox0").click(function() {
$(this).css('color', 'rgb(64, 0, 128)');
});
});
</script>
<style type="text/css">
.textbox0 {
position: fixed;
left: 131px;
top: 38px;
font-family: Arial;
font-size: 8px;
font-weight: normal;
}
</style>
</head>
<body>
<div class="textbox0"><textarea rows=7 cols=30>Change colour</textarea></div>
</body>
</html>
I believe I did everything correctly as this method worked with buttons, but I guess I didn’t.
You need to apply the change to the
textareaelement, not thediv:Here’s a working example.
If you need to keep the
clickevent handler bound to the.textbox0element and not thetextarea, you could use thefind(orchildren) method within the event handler to apply the change to thetextarea: