0

在接下来的例子中:

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

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

如何在 a 包含的所有名称中将 all 替换为 (space %20) ?" "id="TITle"

4

4 回答 4

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.

于 2013-02-22T11:20:59.803 回答
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()));

});
于 2013-02-22T11:21:53.510 回答
0
$("#TITLE").text($("#TITLE").text().replace("%20", " "));
于 2013-02-22T11:21:54.737 回答
0
$('b').each(function (i) {
if ($(this).id=='Title');
{ $(this).text($(this).text().replace("%20", " "));

}
});
于 2013-02-22T12:05:47.633 回答