Behseini
Behseini

Reputation: 6328

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 ?

$( ".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" >

Upvotes: 0

Views: 37

Answers (3)

Vijay
Vijay

Reputation: 431

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" />

Upvotes: 1

guest271314
guest271314

Reputation: 1

Try substituting <input type="text" class="form-control content" /> for <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" />

Upvotes: 1

user3779812
user3779812

Reputation: 230

You have class twice. Try this:

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

Upvotes: 1

Related Questions