prepend(): how to insert "\" before a text?
I want to insert "\" before "*" in jQuery because I cannot do it in javascript.
- <html>
<head>
- <script src="http://code.jquery.com/jquery-1.5.js"></script>
</head>
<body>
<script>
$(function(){
$("span:contains('*')").prepend('<span>\</span>');
});
</script>
<script>
var rename = 1;
for (rename=1;rename<=3;rename++)
{
document.write('<span>' + 'a\*file' + '</span>' + rename + '<br />');
}
</script>
</body>
</html>
Is there wrong with my javascript code? It does not recognise the backward slash.
Because it doesn't print out the backward slash, I want to prepend it before asterisks in jQuery.
However, it does not work either in jQuery.
Could anyone who knows it help me? Many thanks.