2
$('#label-user').click(function(){
if ($('#label-user').style.display != 'none') {
$('#label-user').css('display', 'none');
}
});
good, the jquery
can’t read the part $('#label-user').style.display != 'none'
, and I don’t know how to replace it with something that jquery recognizes, I searched its documentation, but I couldn’t find anything
so q release give as the right answer, vlw man :D
– Murilo Melo
A note, if you don’t want to use . toggle(), which shows when clicking, and hides when clicking again. Use . Hide(), which only enables the hide process.
– Thiago Yoithi
@Thiagoyoithi is not possible to click an element with
display: none;
.– Sergio
@Sergio, yes, exactly for that. I’m giving the alternative of Hide() by making more sense in the context that he presented. Why would he use . toggle() in a click event where the target is $(this)itself? Considering he won’t be able to click again after he’s already hidden? It makes more sense to use Hide(), as it will simply hide the element, without allowing more interactions to this button (which will no longer be on the screen anyway). It was just something that crossed my mind here, rsrsrs... correct me if I’m missing something.
– Thiago Yoithi
@Thiagoyoithi the
.hide()
also makesdisplay: none;
-> https://jsfiddle.net/trpqrjpb/– Sergio
@Sergio, yes I know, all these functions, show(), Hide(), toggle(). They all make use of the display:None; css property. That’s not my point. My point is that it makes no sense to use toggle() on an element that might get hidden, as it will not be possible to reactivate it (this being a $(this target click event)).
– Thiago Yoithi
@Thiagoyoithi ah, I understand, you’re right, semantically it’s more correct to use the
.hide()
, is that right? I’ll correct.– Sergio
@Sergio Exactly! Thanks for understanding.
– Thiago Yoithi
@Thiagoyoithi thanks for the patience :P here is already night and tiredness makes the head slower :)
– Sergio