i've got this
$('#div').attr("hidden", true);
i tried:
var a = $('#div').attr("hidden");
var b = $('#div').attr("hidden").val();
var c = $('#div').hidden;
var a = $('#div').disabled;
i just want to know whether hidden is true or false. does anybody know? my research results are all about forms and inputs.
i've got this
$('#div').attr("hidden", true);
i tried:
var a = $('#div').attr("hidden");
var b = $('#div').attr("hidden").val();
var c = $('#div').hidden;
var a = $('#div').disabled;
i just want to know whether hidden is true or false. does anybody know? my research results are all about forms and inputs.
Share Improve this question asked Apr 4, 2012 at 9:20 p0rterp0rter 9892 gold badges13 silver badges28 bronze badges 2- 1 what does "hidden" mean? i didn't know there was a "hidden" attribute for a div. – Joseph Commented Apr 4, 2012 at 9:21
- What are you trying to do? hide the div or store a value in the attributes? – gdoron Commented Apr 4, 2012 at 9:27
3 Answers
Reset to default 9attribute will never be true
, it can have strings only.
jQuery has the data
functions for objects other than strings:
$('#div').data("hidden", true); // set the "hidden" data
var flag = $('#div').data("hidden"); // get the "hidden" data (true)
If you wanted to hide the div
, use .hide()
:
$('#div').hide();
And you check if the div is visible with :visible
\ :hidden
$('#div').is(':visible'); // Or $('#div').is(':hidden')
Alternatively you could use
$('#div').toggle(showOrHide);
where showOrHide is a bool of true of false to hide or show.
This is the same as doing
if ( showOrHide == true ) {
$('#div').show();
} else if ( showOrHide == false ) {
$('#div').hide();
}
Hope this helps
i think you mean jquery visible
.is(':visible')