简体   繁体   English

jQuery textchange插件不起作用

[英]jQuery textchange plugin doesn't work

I have tried to add "jQuery textchange plugin" to my code. 我试图将“ jQuery textchange插件”添加到我的代码中。 Here it is: http://www.zurb.com/playground/jquery-text-change-custom-event 在这里是: http : //www.zurb.com/playground/jquery-text-change-custom-event

Here are the parts of my code, I think it will be enough: 这是我的代码的一部分,我认为就足够了:

page.html: page.html:

//...other code
<script type="text/javascript" src="resources/javascripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="resources/javascripts/jquery.textchange.js"></script>
<script type="text/javascript" src="resources/javascripts/formscript.js"></script>
//...other code 

//...
<input type="text" placeholder='placeholder' class='necess'>
//...other code

fornscritp.js: fornscritp.js:

//...other code

$(document).ready(function() {
    $(".necess").bind("hastext", function () {
        alert('YES');
    });
});

So I want to see the message 'YES' when I'm start typing something into my INPUT, but unfortunately it didn't work. 因此,当我开始在INPUT中输入内容时,我想看到消息“是”,但不幸的是它没有用。

I try this with "textchange" and try to change tag from INPUT to TEXTAREA like on the examples on the site, but it also didn't help. 我尝试使用“ textchange”尝试此操作,并尝试将标签从INPUT更改为TEXTAREA,如该站点上的示例一样,但这也没有帮助。

I spent hours and tryed to GOOGLE IT but didn't find the answer. 我花了几个小时尝试使用GOOGLE IT,但没有找到答案。 Even thought that I uset this plugin wrong. 甚至以为我用这个插件错了。

Tell me please what am I doing wrong! 告诉我我在做什么错!

So, I think I've found the answer. 所以,我想我已经找到了答案。 It's everything right on the code above. 以上就是上面代码中的所有内容。 But I also had some 'script' line where I've added another jQuery library. 但是我也有一些“脚本”行,在其中添加了另一个jQuery库。 When I deleted this line everything started work. 当我删除此行时,一切开始工作。 I found this mistake by analyzing the code and resources of this page: 我通过分析此页面的代码和资源发现了这个错误:

http://www.zurb.com/playground/jquery-text-change-custom-event http://www.zurb.com/playground/jquery-text-change-custom-event

(just download everything, and comment each line while found something which may cause the bug, but didn't found) So, now everything works. (只需下载所有内容,然后在每行中添加注释,同时找到可能导致该错误的内容,但未找到)。因此,现在一切正常。 The only advice I can give to someone with the mistakes like this is to be more attentive to your code:) 我可以给遇到此类错误的人的唯一建议是更注意您的代码:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM