Skip to main content
Active reading.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

jquery on On click get input value using jQuery

I have the following:

$('.checkbox').click(function () { console.log(this); $.ajax({ type:'POST', url: '/loadProducts', data: {}, success: function(response) { console.log(response); $('.js-products').html(response); }}); return false; }); 

Now where I do the console.log(this), it returns:

<div class="ui checkbox checked"> <input type="checkbox" name="gender[Women]" tabindex="0" class="hidden"> <label>Women</label> </div> 

How do I get the input name (gender)? And whether the checkbox is checked out or not?

jquery on click get input value

I have the following:

$('.checkbox').click(function () { console.log(this); $.ajax({ type:'POST', url: '/loadProducts', data: {}, success: function(response) { console.log(response); $('.js-products').html(response); }}); return false; }); 

Now where I do the console.log(this), it returns:

<div class="ui checkbox checked"> <input type="checkbox" name="gender[Women]" tabindex="0" class="hidden"> <label>Women</label> </div> 

How do I get the input name (gender)? And whether the checkbox is checked out not?

On click get input value using jQuery

I have the following:

$('.checkbox').click(function () { console.log(this); $.ajax({ type:'POST', url: '/loadProducts', data: {}, success: function(response) { console.log(response); $('.js-products').html(response); }}); return false; }); 

Now where I do the console.log(this), it returns:

<div class="ui checkbox checked"> <input type="checkbox" name="gender[Women]" tabindex="0" class="hidden"> <label>Women</label> </div> 

How do I get the input name (gender)? And whether the checkbox is checked out or not?

Post Closed as "Duplicate" by user400654 javascript
format for clarity
Source Link
Mark Schultheiss
  • 34.3k
  • 13
  • 75
  • 116

I have the following:

$('.checkbox').click(function () {   console.log(this);   $.ajax({   type:'POST',   url: '/loadProducts',   data: {},   success: function(response) {   console.log(response);   $('.js-products').html(response);   }});   return false;  }); 

Now where I do the console.log(this)console.log(this), it returns:

<div class="ui checkbox checked">   <input type="checkbox" name="gender[Women]" tabindex="0" class="hidden">   <label>Women</label>  </div> 

How do I get the input name (gender)? And whether the checkbox is checked out not?

I have the following:

$('.checkbox').click(function () {   console.log(this);   $.ajax({   type:'POST',   url: '/loadProducts',   data: {},   success: function(response) {   console.log(response);   $('.js-products').html(response);   }});   return false;  }); 

Now where I do the console.log(this), it returns:

<div class="ui checkbox checked">   <input type="checkbox" name="gender[Women]" tabindex="0" class="hidden">   <label>Women</label>  </div> 

How do I get the input name (gender)? And whether the checkbox is checked out not?

I have the following:

$('.checkbox').click(function () { console.log(this); $.ajax({ type:'POST', url: '/loadProducts', data: {}, success: function(response) { console.log(response); $('.js-products').html(response); }}); return false; }); 

Now where I do the console.log(this), it returns:

<div class="ui checkbox checked"> <input type="checkbox" name="gender[Women]" tabindex="0" class="hidden"> <label>Women</label> </div> 

How do I get the input name (gender)? And whether the checkbox is checked out not?

Post Reopened by guest271314 javascript
Post Closed as "Duplicate" by ssube, rlemon, Zakaria Acharki javascript
Source Link
strangeQuirks
  • 6.1k
  • 11
  • 49
  • 87

jquery on click get input value

I have the following:

$('.checkbox').click(function () { console.log(this); $.ajax({ type:'POST', url: '/loadProducts', data: {}, success: function(response) { console.log(response); $('.js-products').html(response); }}); return false; }); 

Now where I do the console.log(this), it returns:

<div class="ui checkbox checked"> <input type="checkbox" name="gender[Women]" tabindex="0" class="hidden"> <label>Women</label> </div> 

How do I get the input name (gender)? And whether the checkbox is checked out not?