编辑Shopify应用。除非您在文本区域之外单击,否则文本区域中的最后一个字符不会在标签图片上大写。
$(function() {
$('#cstedit-addembossing').keyup(function() {
this.value = this.value.toUpperCase();
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea maxlength="10" data-area="back" class="customify-text" data-target="addembossing" id="cstedit-addembossing" placeholder="Write a name, special date, quote, and the list goes on"></textarea>
答案 0 :(得分:2)
您可能正在寻找与keyup
不同的事件。 input
最适合您要执行的imo。
$(function() {
$('#cstedit-addembossing').on("input", function() {
this.value = this.value.toUpperCase();
});
});
答案 1 :(得分:0)
// those listeners are added by customizer-final-v33.js
foo.addEventListener('change', e => display.textContent = foo.value);
foo.addEventListener('input', e => display.textContent = foo.value);
// this is basically your listener
foo.addEventListener('keyup', e => foo.value = foo.value.toUpperCase());
<textarea id="foo"></textarea>
<hr />
<h1 id="display">Type and texarea will update this text.</h1>
要解决此问题,请继续:
// those listeners are added by customizer-final-v33.js
foo.addEventListener('change', e => display.textContent = foo.value);
foo.addEventListener('input', e => display.textContent = foo.value);
// this is basically a working version your listener
foo.addEventListener('keydown', (e) => {
event.preventDefault();
foo.value = foo.value + String.fromCharCode(e.keyCode).toUpperCase();
foo.dispatchEvent(new CustomEvent('input', { bubbles: true }));
})
<textarea id="foo"></textarea>
<hr />
<h1 id="display">Type and texarea will update this text.</h1>