Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

checkbox value in jquery

i'm using Mvc checkbox.

by default the rendering a checkbox like below.

<input id="tets" type="checkbox" value="true" name="test"/>
<input type="hidden" value="false" name="test"/>

so whn itry to access

$("#tets").val() returns true, but defaultly it is false.

Any idea how to access checkbox using jquery

like image 752
Santhosh Avatar asked Oct 06 '09 10:10

Santhosh


People also ask

How to check a checkbox dynamically with jQuery?

How to check a checkbox with jQuery? There are two methods by which you can dynamically check the currently selected checkbox by changing the checked property of the input type. Method 1: Using the prop method: The input can be accessed and its property can be set by using the prop method. This method manipulates the ‘checked’ property ...

How to select input elements with type=checkbox in jQuery?

❮ jQuery Selectors Example Select all <input> elements with type="checkbox": $(":checkbox") Try it Yourself » Definition and Usage The :checkbox selector selects input elements with type=checkbox. Syntax $(":checkbox")

What do the checkbox attributes mean in jQuery?

as explained in the official documentations in jQuery's website. The rest of the methods has nothing to do with the property of the checkbox, they are checking the attribute which means they are testing the initial state of the checkbox when it was loaded. So in short:

How to get multiple selected checkbox values in array format using jQuery?

Get multiple selected checkbox value in an array format using jQuery join function. Click multiple check boxes to get value on click of the button given above. The array can be useful to get multiple selection values and get user input form data.


1 Answers

var value = $("#tets").is(":checked");
like image 163
takepara Avatar answered Oct 19 '22 03:10

takepara