0

in the next examples :

 <b id="TITLE">The%20Vampire%20Diaries</b>

 <b id="TITLE"> How%20I%20met%20your%20moom</b>

how can i replace all %20 with " "(space) in all the names that a contained in id="TITle" ?

Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162
VicToR Sava
  • 101
  • 1
  • 4
  • 10

4 Answers4

4

Use unescape():

$("#TITLE").text(function(i,v){
    return unescape(v);
});

Live Demo: http://jsfiddle.net/rm8GU/1


FYI: In case both elements in your example exist in the same document, ID should be unique, and you should use class references instead.

Curtis
  • 101,612
  • 66
  • 270
  • 352
0

You shouldn't have 2 items with the same ID. Try using a class instead, then iterating the classes.

$('.TITLE').each(function(){

    $(this).text(unescape($(this).text()));

});
sjdaws
  • 3,466
  • 16
  • 20
0
$("#TITLE").text($("#TITLE").text().replace("%20", " "));
Selvaraj M A
  • 3,096
  • 3
  • 30
  • 46
0
$('b').each(function (i) {
if ($(this).id=='Title');
{ $(this).text($(this).text().replace("%20", " "));

}
});
Sandeep
  • 46
  • 2