如何在IE中使用Quoctout.js的搜索框的交叉标记添加任何事件/功能?

发布于 2025-01-24 05:42:41 字数 82 浏览 1 评论 0原文

我正在尝试使用QuintOut.js在搜索框中的交叉标记上添加事件/功能,无法找到任何解决方案。有人知道如何仅使用quotionut.js做到这一点?

I'm trying to add event/function on cross mark in search box with knockout.js, couldn't able to find any solution. Anyone have idea how to do it by using only knockout.js?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

菊凝晚露 2025-01-31 05:42:41

没有针对此的具体事件,但是输入字段会fire 更改INPUT事件。因此,您可以聆听这些内容,也可以订阅与搜索输入绑定的可观察到的可观察到的。如果新值是一个空字符串,则清除输入字段,您可以做一些事情。

function ViewModel() {
    this.searchTerm = ko.observable();
    this.searchTerm.subscribe((newVal) => {
        if (newVal === '') {
            console.log('Input was cleared');
        }
    });
}

ko.applyBindings(new ViewModel());
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>

<input type="search" data-bind="textInput: searchTerm" />

There is no specific event for this, but input fields do fire change and input events. So you can either listen to those, or just subscribe to the observable that's bound to the search input. If the new value is an empty string, the input field was cleared and you can do stuff.

function ViewModel() {
    this.searchTerm = ko.observable();
    this.searchTerm.subscribe((newVal) => {
        if (newVal === '') {
            console.log('Input was cleared');
        }
    });
}

ko.applyBindings(new ViewModel());
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>

<input type="search" data-bind="textInput: searchTerm" />

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文