Как изменить значение текста внутри элемента? Как вы изменяете текст для всех в пределах a до продолжить чтение с помощью jquery <div class="post-read"> <a href="#" onclick="location.href='http://www.google.com'; return false;">Read More</a> </div> Ответ 1 Сделайте это с помощью jQuery внутри обработчика документа ($(fn))... $('.post-read a').text('continue reading'); jsFiddle. Ради этого, вот как это сделать без jQuery.... var anchor = document.getElementsByClassName('post-read')[0].getElementsByTagName('a')[0], textProperty; if (anchor.textContent) { textProperty = 'textContent'; } else if (anchor.innerText) { textProperty = 'innerText'; } anchor[textProperty] = 'continue reading'; jsFiddle. Это будет полезно для вашего фрагмента HTML, но оно не является слишком общим. Если вам не нужно устанавливать свойство innerText, вы можете использовать... anchor.textContent = anchor.innerText = 'continue reading'; Я бы не рекомендовал его. Ответ 2 Это должно сделать это: $('.post-read a').html('continue reading'); Ответ 3 $('.post-read a').html("continue reading") Ответ 4 Через свойство text в jQuery, которое изменяет внутренний текст <tag> $(document).ready(function () { $('.postread a').text("your new text here "); }
Ответ 1 Сделайте это с помощью jQuery внутри обработчика документа ($(fn))... $('.post-read a').text('continue reading'); jsFiddle. Ради этого, вот как это сделать без jQuery.... var anchor = document.getElementsByClassName('post-read')[0].getElementsByTagName('a')[0], textProperty; if (anchor.textContent) { textProperty = 'textContent'; } else if (anchor.innerText) { textProperty = 'innerText'; } anchor[textProperty] = 'continue reading'; jsFiddle. Это будет полезно для вашего фрагмента HTML, но оно не является слишком общим. Если вам не нужно устанавливать свойство innerText, вы можете использовать... anchor.textContent = anchor.innerText = 'continue reading'; Я бы не рекомендовал его.
Ответ 4 Через свойство text в jQuery, которое изменяет внутренний текст <tag> $(document).ready(function () { $('.postread a').text("your new text here "); }