Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change attribute "hidden" in jquery

<td> <input id="check" type="checkbox" name="del_attachment_id[]" value="<?php echo $attachment['link'];?>"> </td>  <td id="delete" hidden="true"> the file will be deleted from the newsletter </td> 

I want to know how can i change the attribute "hidden" to false in Jquery when the checkbox is checked or not checked.

like image 791
user3314813 Avatar asked Jun 12 '15 17:06

user3314813


People also ask

How to hide attribute in jQuery?

jQuery hide() MethodThe hide() method hides the selected elements. Tip: This is similar to the CSS property display:none. Note: Hidden elements will not be displayed at all (no longer affects the layout of the page). Tip: To show hidden elements, look at the show() method.

How do I change attribute values?

To change the attribute value of an HTML element HTML DOM provides two methods which are getAttribute() and setAttribute(). The getAttribute() is used to extract the current value of the attribute while setAttribute() is used to alter the value of the attribute.

Is visible in jQuery?

The :visible selector in jQuery is used to select every element which is currently visible. It works upon the visible elements. The elements that are consuming space in the document are considered visible elements. The height and width of visible elements are larger than 0.


2 Answers

$(':checkbox').change(function(){     $('#delete').removeAttr('hidden'); }); 

Note, thanks to tip by A.Wolff, you should use removeAttr instead of setting to false. When set to false, the element will still be hidden. Therefore, removing is more effective.

like image 112
AmmarCSE Avatar answered Oct 09 '22 02:10

AmmarCSE


You can use jquery attr method

$("#delete").attr("hidden",true); 
like image 40
Anoop Joshi P Avatar answered Oct 09 '22 03:10

Anoop Joshi P