jQuery HTML Element How to - Switch element content








Question

We would like to know how to switch element content.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--  w  ww . jav a2  s.  c  om-->
    $('.email_me a').html('<img src="http://www.java2s.com/style/download.png">');
});
</script>
</head>
<body>
  <div class="email_me">
    <a href="mailto:info@mydomain.com">info@mydomain.com</a>
  </div>
</body>
</html>

The code above is rendered as follows: