-2

This is my html checkbox --

<input type="checkbox" id="export_1_field_title" value="title">

in jquery, i want to check whether checkbox is checked or not, if check then will read the value, so this is my query --

                var title = '';
                if($("#export_1_field_title").is("checked"))
                {
                    title = 'title';
                }
                alert('Here '+title);

but not able to read the checkbox, kindly suggest any changes required

Rana Pratap
  • 55
  • 1
  • 9

1 Answers1

2

To check if it is checked (You forgot :) :

$("#export_1_field_title").is(":checked")

To extract the value :

title = $("#export_1_field_title").val();
Sébastien S.
  • 1,444
  • 8
  • 14