admin管理员组文章数量:1429988
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);
});
本文标签: javascriptFind and replace dollar sign with rupee symbol using jQueryStack Overflow
版权声明:本文标题:javascript - Find and replace dollar sign with rupee symbol using jQuery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745522836a2661704.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论