В HTML у меня есть
code exchange org <sup></sup>
есть пространство после org. Мне нужно удалить это пространство. сделать так
code exchange org<sup></sup>
Я использую jquery
$(div).each(function(){
$(this).text("org <sup>").replace("org<sup>");
});
Демо- версия http://jsfiddle.net/krasimir/yFA4S/
$("div").each(function(){
$(this).html($(this).html().replace("org <sup>", "org<sup>"));
});
Вы не используете метод replace
правильно
Они это
$(div).each(function(){
this.innerHTML = this.innerHTML.replace('org <sup>','org<sup>');
});
Вам также необходимо присвоить измененное значение
$(your div here).each(function(){
this.innerHTML = this.innerHTML.replace(' <sup>','<sup>');
});
Пытаться
$('div').each(function(){
this.innerHTML = this.innerHTML.replace(' <sup>','<sup>');
});
или
$('div').each(function(){
$(this).html( $(this).html().replace(' <sup>','<sup>'));
});
Рекомендации
это должно сделать это: $(this).text( $(this).text().replace("group <","group<") );
Надеюсь, я был первым, надеюсь, я тебе помог.
Пытаться
$('div sup').each(function () {
var prev = this.previousSibling;
if (prev && prev.nodeType == 3) {
prev.textContent = $.trim(prev.textContent)
}
});
Демо: скрипка