jQuery Page Widget How to - Click to Change color of span text








Question

We would like to know how to click to Change color of span text.

Answer


<!--from   ww w. ja  v  a  2  s . com-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.8.3.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    $('span.disabled').click(function () {
        $('.disabled').css("color", "red");
    });
});
</script>
</head>
<body>
  <span class="disabled">test</span>
</body>
</html>

The code above is rendered as follows: