0% found this document useful (0 votes)
6 views1 page

Notes For Me (UV)

The document discusses different ways to hide and show HTML elements using JavaScript and jQuery, including using the style display property, adding and removing CSS classes, and adding/removing HTML attributes. It also provides examples of how to get the checked values of checkboxes and manipulate the checked/unchecked states of checkboxes and radio buttons using JavaScript and jQuery.

Uploaded by

Ankita Ashal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Notes For Me (UV)

The document discusses different ways to hide and show HTML elements using JavaScript and jQuery, including using the style display property, adding and removing CSS classes, and adding/removing HTML attributes. It also provides examples of how to get the checked values of checkboxes and manipulate the checked/unchecked states of checkboxes and radio buttons using JavaScript and jQuery.

Uploaded by

Ankita Ashal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

how to hide and show element or tag using js and jquery?

- there are many ways few of them are listed below.


1. using js you can target that element by it's id and than element.style.display =
'none' or hidden
and if we want to use jquery than targetElemnet.hide() or show.
2. we can add d-none class to the element than we can removeclss from javaScript
and jquery both.
element.ClassList.remove('d-none') or element.removeclass('d-none') using jquery.
3. we can add hidden attribute and than we can removeAttrivute using both
javascript and jquery.
element.RemoveAttriute('hidden') or element.removeAttr('hidden') simmilarlly we
can also add
the attribute also using setattribute or attr.

how can we get the checked value of checkbox ?


- using jquery we can very easily get it.
simply we have to create one empty arraylist to store the checked value.
than we have to use this syntax:
$('input[name="nameOFCheckbox"]:checked').each(function(){
arraylist.push($(this).val());
});
this is a simple syntax of it.

how to manipulate the checked and unchecked value of checkbox.


- we can do this simply using javascript and jquery.
using javascript:- document.querySelector('input[name="checkboxName"]
[value="valueYouWantToManipulate"]').checked = true/false
using jquery:- $('input[name="checkBoxName"]
[value="valueToManipulate"]').prop('checked',true/false);

for the radio button we can do same the thing to manipulate check and uncheck radio
button.
and to get the value of it we can simply use jquery or javascript
$('input[name="gender"]:checked').val();

You might also like