I have ,
`<span class="icon">►</span>`
in Jquery I did,
$(this).html('▼');
and tried $(this).replaceWith('▼');
too.
but it displays '▼
' instead of converting it to a html icon like ▼.
thanks
I have ,
`<span class="icon">►</span>`
in Jquery I did,
$(this).html('▼');
and tried $(this).replaceWith('▼');
too.
but it displays '▼
' instead of converting it to a html icon like ▼.
thanks
Why not just hardcode the unicode literal?
$('<span>').text('▼').appendTo('body')
You have to make sure you're serving the js file as UTF-8 though.
Edit: .html()
should also work fine..
$('<span>').html('▼').appendTo('body')
Make sure the this
reference is pointing to the correct object, you can do var foo = this; before switching function scope.
What is this
referring to? I think you might not be the span
tag. Here's a working example.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('span.icon').html('▼');
});
</script>
</head>
<body>
<span class="icon">►</span>
</body>
</html>