I solved it with following
jQuery(document).ready(function() {
jQuery('#cstm_content a').attr('href', function (_, href) {
var charMap = {Ç:'c',Ö:'o',Ş:'s',İ:'i',I:'i',Ü:'u',Ğ:'g',ç:'c',ö:'o',ş:'s',ı:'i',ü:'u',ğ:'g'};
return href.replace(/Ç|Ö|Ş|İ|I|Ü|Ğ|ç|ö|ş|ı|ü|ğ/g, function(matched){
return charMap[matched];
});
});
});
jQuery(document).ready(function() {
jQuery('.cstm_title h3').attr('id', function (_, id) {
var charMap = {Ç:'c',Ö:'o',Ş:'s',İ:'i',I:'i',Ü:'u',Ğ:'g',ç:'c',ö:'o',ş:'s',ı:'i',ü:'u',ğ:'g'};
return id.replace(/Ç|Ö|Ş|İ|I|Ü|Ğ|ç|ö|ş|ı|ü|ğ/g, function(matched){
return charMap[matched];
});
});
});
I wanted to change id and another element href value which are created dynamically
I did this and it is working for id but not working with href it is
jQuery(document).ready(function() {
jQuery('.cstm_title h3').each(function(){
var charMap = {Ç:'c',Ö:'o',Ş:'s',İ:'i',I:'i',Ü:'u',Ğ:'g',ç:'c',ö:'o',ş:'s',ı:'i',ü:'u',ğ:'g'};
this.id = this.id.replace(/Ç|Ö|Ş|İ|I|Ü|Ğ|ç|ö|ş|ı|ü|ğ/g, function(matched){
return charMap[matched];
});
});
});
jQuery(document).ready(function() {
jQuery('#cstm_content a').each(function(){
var charMap = {Ç:'c',Ö:'o',Ş:'s',İ:'i',I:'i',Ü:'u',Ğ:'g',ç:'c',ö:'o',ş:'s',ı:'i',ü:'u',ğ:'g'};
this.href = this.hash.substr(1).replace(/Ç|Ö|Ş|İ|I|Ü|Ğ|ç|ö|ş|ı|ü|ğ/g, function(matched){
return charMap[matched];
});
});
});
And this is the result for id it is working but for href not working.
<div class="test"><div id="cstm_content" class="list-group">
<a class="list-group-item list-group-item-action" href="%C4%B0zmir">İzmir</a>
<a class="list-group-item list-group-item-action" href="%C3%9Csk%C3%BCp">Üsküp</a>
</div>
<div data-spy="scroll" data-target="#cstm_content" data-offset="30" class="scrollspy-example">
<div class="cstm_card">
<div class="cstm_title">
<h3 class="cstm_c_title" id="izmir">İzmir</h3>
<p class="cstm_c">Here is paragraph</p>
<h3 class="cstm_c_title" id="uskup">Üsküp</h3>
<p class="cstm_c">Here is paragraph</p>
</div>
</div>
</div>
I am beginner in jquery I am creating all with googleing but couldn’t find solution for this. If there is easier method that you will provide I will be happy.
Ok, not sure if I really understood the problem then. Where did example.com come from? It the link is like that you could split href: var urlArray = this.href.split(‘#’); this.href =’#’ + urlArray[1].replace(‘…
@Svela Thank you so much with your help. I have dynamically created element attributes that have Turkish characters and with Jquery I want to replace Turkish characters with English ones. Maybe you can have another solution to solve it.?