(function () {
'use strict';
// 获取备注日期 + ZHUAN
function getRemarkDate() {
let date = new Date();
let month = (date.getMonth() + 1).toString();
let today = date.getDate().toString();
return month + '.' + today + ' ZHUAN'
}
// 编辑文本框
function editTextInputByReact(selector) {
setInterval(function () {
let element = document.querySelector(selector);
let inputValue = element.value + ' ' + getRemarkDate() + ' ';
let valueSetter = Object.getOwnPropertyDescriptor(element, 'value').set;
let prototype = Object.getPrototypeOf(element);
let prototypeValueSetter = Object.getOwnPropertyDescriptor(prototype, 'value').set;
element.onclick = function () {
if (element.value.indexOf(getRemarkDate()) === -1) {
if (valueSetter && valueSetter !== prototypeValueSetter) {
prototypeValueSetter.call(element, inputValue)
} else {
valueSetter.call(element, inputValue)
}
}
}
element.dispatchEvent(new Event('input', {bubbles: true}))
}, 100)
}
//执行
window.onload = function () {
editTextInputByReact('#seller_words')
}
})();
实现的需求就是点击文本框执行追加赋值,现在出现问题了,需要赋值保存两次才可以 就是第一次赋值保存,系统并没有保存成功,需要再次赋值保存一次 才可以 太浪费时间了 问题出在哪了 求助大佬
用while直至找到你的id为止break