简体   繁体   English

jQuery在文本输入单击上不起作用

[英]jQuery Not Functioning on Text Input Click

Can you please take a look at this code and let me know why the click event is not firing ? 您能否看一下这段代码,让我知道为什么click事件没有触发?

 $( ".content" ).on("click", function() { alert( "This is Clicked" ); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> <input type="text" class="form-control" class="content" > 

You have class twice. 你有两次class Try this: 尝试这个:

<input type="text" class="content form-control" >

Try substituting <input type="text" class="form-control content" /> for <input type="text" class="form-control" class="content" > 尝试用<input type="text" class="form-control content" />替换<input type="text" class="form-control content" /> <input type="text" class="form-control" class="content" >

 $(".content").on("click", function() { alert("This is Clicked"); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"> </script> <input type="text" class="form-control content" /> 

Try this 尝试这个

 $(document).ready(function(){ $('.content').click(function(){ alert('I have done'); }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <input type="text" class="form-control content" /> 

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

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