Содержимое текстовой области не пусто после его удаления.Jquery

Программирование на jquery
Ответить
Гость
 Содержимое текстовой области не пусто после его удаления.

Сообщение Гость »


У меня есть простая текстовая область в HTML, например: Now let's say there is text in this textarea, because it loads something from the database and puts it in there:

Код: Выделить всё

Here is some text from the database

Now when I delete that text manually by pressing the return key on my keyboard, the text gets deleted visually. But when I inspect the element it still says that text is in there.
The problem here is that there is a specific button which appears when there is no text in the textarea. This also works as intended. This button has a function that generates text in that textarea on click. If there is text in that area, a jquery popup will appear, asking the user if he wants to override the current text. But there is no text, because I deleted it. So the popup comes, because on inspecting the element, you can still see the text, although I deleted it.

Код: Выделить всё

    const $textfield = $('#sitetitle');

if ($textField.text().trim() !== '' || $textField.val().trim() !== '') {
console.log($textField.text().trim());
console.log($textField.val().trim());
overrideConfirmDialog($response, $textField, $generationButton, seoOptionPart);
} else {
$textField.text($response);
updateAllCheckFields();
}


Источник: https://stackoverflow.com/questions/781 ... eleting-it
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Jquery»