This is my code in which I am trying to replace Dollar Symbol $
with INR(Indian Rupee) using jQuery, however it is not working as this is only a specimen code so it is not ul >li
and find text
and replace text
kinda thing, my tries goes like this- I tried to first gather whole HTML and then replace $
sign with the code, but its not making anyhow.
My assumption - in $(document).ready()
using $(this)
inside this snippet refers to the document, let me know if this is a false assumption, as I tried my attempts keeping this thing in mind.
Please DO NOT
give any links/referrals to do it in CSS way or Webrupee API usage, keep it simple to jQuery this time :)
My Code -
<!DOCTYPE html>
<html>
<head>
<title>Rupee Change - jQuery Flavour</title>
</head>
<body>
<p>This is a price listing with $ sign, Now I wanted to replace each dollar sign with rupee symbol</p>
<ul>
<li>$ 500</li>
<li>$ 600</li>
<li>$ 700</li>
<li>$ 800</li>
<li>$ 900</li>
</ul>
<div id="showhtml"></div>
<script src=".js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(this).html().replace("$", "<del>र</del>");
});
</script>
</body>
</html>
FYI - I also tried this way of handling but not working :( find-text-string-using-jquery
This is my code in which I am trying to replace Dollar Symbol $
with INR(Indian Rupee) using jQuery, however it is not working as this is only a specimen code so it is not ul >li
and find text
and replace text
kinda thing, my tries goes like this- I tried to first gather whole HTML and then replace $
sign with the code, but its not making anyhow.
My assumption - in $(document).ready()
using $(this)
inside this snippet refers to the document, let me know if this is a false assumption, as I tried my attempts keeping this thing in mind.
Please DO NOT
give any links/referrals to do it in CSS way or Webrupee API usage, keep it simple to jQuery this time :)
My Code -
<!DOCTYPE html>
<html>
<head>
<title>Rupee Change - jQuery Flavour</title>
</head>
<body>
<p>This is a price listing with $ sign, Now I wanted to replace each dollar sign with rupee symbol</p>
<ul>
<li>$ 500</li>
<li>$ 600</li>
<li>$ 700</li>
<li>$ 800</li>
<li>$ 900</li>
</ul>
<div id="showhtml"></div>
<script src="http://code.jquery./jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(this).html().replace("$", "<del>र</del>");
});
</script>
</body>
</html>
FYI - I also tried this way of handling but not working :( find-text-string-using-jquery
Share Improve this question edited May 23, 2017 at 11:57 CommunityBot 11 silver badge asked Apr 20, 2013 at 12:11 swapneshswapnesh 26.7k24 gold badges97 silver badges129 bronze badges 2- 1 you need to reassign it back to the html. $(this).html($(this).html().replace("$", "<del>र</del>")); – Parthik Gosar Commented Apr 20, 2013 at 12:30
- @ParthikGosar not working :( – swapnesh Commented Apr 20, 2013 at 12:33
1 Answer
Reset to default 4$ is a special character in Regex. You will need to escape it.
$(document).ready(function(){
var replaced = $('body').html().replace(/\$/g, "<del>र</del>");
$('body').html(replaced);
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745522837a4631338.html
评论列表(0条)