Consider the following DOM manipulation problem: I need to create a span tag after clicking on some link. Because of speeding up the process I prefer using document.createElement()(pure Javascript) instead of the Jquery methods of creating HTML elements. The following code compiles properly but isn't working (maybe because of interferention between Javascript and Jquery). Any help will be greatly appreciated.
<body>
<a href="#">Create thumbnails</a>
<script type="text/javascript">
$('a').click(function(e) {
var newSpan=null;
newSpan = document.createElement('span');
newSpan.setAttribute('class','themes');
$('.themes').html('themes');
$('.themes').appendTo('body');
return false;
});
</script>
</body>
.setAttribute('class','themes');may give you trouble inIE6. If you're supportingIE6, you may want to use.setAttribute('className','themes');instead.