<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.
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.
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.
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.
$(':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.
You can use jquery attr method
$("#delete").attr("hidden",true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With