how to disable this document.getElementById("failedUpdateMessage").style.visibility = "hidden"; in javascript - javascript

after I used that code to hide the element with the id "failedUpdateMessage", I would like to show that hidden element in some page in html, how would I do that using java script? I'd try to replace the "hidden" to "show" but it doesn't work.

You must use :
document.getElementById("failedUpdateMessage").style.visibility ="visible";
Note : show() works on elements hidden with jQuery methods and display:none in CSS (but not visibility:hidden).

Look up the visibility property. See what values are acceptable. Don't guess. show isn't one of them. visible is.

Related

How can I keep Html element hide() without using jQuery and show using jQuery.show()?

I want to make my htmlelement hide while the page renders. For this I set display:none. However, when I use $.show(), the element isn't showing up. I want to make the element show using $.show() itself. Please help!
Yes. jQuery or the browser rendering engine has a problem with this. If you are not using any animation, you can very well define a class:
.hidden {display: none;}
And using jQuery, you can remove the class by:
$(element).hide().removeClass("hidden").fadeIn();
$(element).toggleClass("hidden");
Now, this on execution, hides the DOM, removes the CSS class and then fades in!
Use the below code:
$("element_Selector").css("display","block");
Looks like there might be 2 issues in such cases..
Either you are not waiting until the DOM is ready .. Encase you code inside $(function() { });
Else style="display:none"
Is taking precedence and your div will never be seen.
To counter that add a class to the element. .hide { display : none }
And then $(selector).show() should get the work done.

Hiding button in JQuery using .prop(hidden: true)

I am trying to figure out how to hide a button with JQuery using the .prop(hidden: true) method. For some reason, in Chrome when I set this value and view the html, the button has a hidden element, but the button still shows up as visible on the page.
Any ideas?
A button does'nt have a hidden property ?
$('button').hide();
or
$('button').toggle(true); //shows button
$('button').toggle(false); //hides button
You can use set the display style to none. For example,
$("#button").css("display", "none");
Or, .hide() for brevity,
$("#button").hide()
There's also visibility and opacity but these two may not generate the effect you desired.
You can't hide a button using jQuery's .prop() function, you have to use either .hide() or .fadeOut() or you can try with .css() method:
using .css():
$('input[submit]').css('display','none');
using fadeOut():
$('input[submit]').fadeOut();
using .hide():
$('input[submit]').hide();
Your syntax is incorrect, but there's no "hidden" property anyway. You probably want:
$('#your_button').hide();
or possibly
$('#your_button').addClass('hidden');
if you've got a "hidden" class in your CSS.
The incorrect part of your syntax is that the parameters to your function call are expressed incorrectly. Setting a property should look like:
$("#your_button").prop("name", "value");
jQuery.prop is intended for HTML attributes only, things defined on the DOM node. CSS styles aren't applicable things to set with prop, and hidden just doesn't exist, whereas href or class is applicable. Instead you must use $(el).css('display', 'none') or $(el).hide().
What you described is actually correct if you happen to use jquery alongside bootstrap4.
just do the following:
$element.prop('hidden', true);
If no bootstrap 4 available it is still works for modern browser.
prop() is a getter function: http://api.jquery.com/prop/ I suggest using hide: http://api.jquery.com/hide/
If you want to use prop, then
$("#my_button").prop("style").display="none"
I would go w/o jquery. (back to the basic)
document.getElementById("mybutton").style.display = "none";
You can use a ternary operator and the css() method to accomplish the same thing: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator
$("#button").css("display", (mycondition) ? "block" : "none");

Remove block with Javascript without "hidden" css styles

I have a problem - I want to DELETE the div's rather than just hide them with css on my web page. I'm newbie in Javascript and I can not say for sure whether this is but I think that should be used function removeChild(). Here's the script:
http://jsbin.com/ufoyor/edit#javascript,html/
It works like this:
1) "X" button hide pronto and crossClose divs due to the fact-purpose style of "hidden" these blocks.
2) The script sets a specific value in a cookie if the value matched the block is not shown (with style = "visibility: hidden;").
Yes, you can remove the element together with its subtree with removeChild().
However, for I suggest setting style display: none. It won't display at all (won't occupy the space as visibility:hidden does).
In plain JavaScript use removeChild(): https://developer.mozilla.org/En/DOM/Node.removeChild
In jQuery you have method remove(): http://api.jquery.com/remove/

using javascript find div tag display property is none or block or undefined

using that code i am able to find tag display propery
but i want to get all the tag which have their display property none.Give me the result using javascript or jquery
document.getElementById('MSO_ContentTable').style.display
MSO_ContentTable is an id of div tag
$('div').filter(function() {
return $(this).css('display') == 'none'; //or whatever you want to filter.
})
See it in action.
$(':hidden')
That should do just fine for you.
Using jQuery you can try the below code to find all the elements which are hidden on the page
$("*").is(":hidden").not("input:hidden");
If a jquery solution is okay you could do:
$('*:not(:visible)')
this returns a collection of all non visible objects in the dom.
These are elements that:
They have a CSS display value of none.
They are form elements with type="hidden".
Their width and height are explicitly set to 0.
An ancestor element is hidden, so the element is not shown on the page
You could filter out only those with "display:none" by iterating on them
Try this code :
$("#MSO_ContentTable").css("display","none");
Using Jquery ,
All document by id "MSO_ContentTable" is Gone ....

jQuery add class based on CSS characteristics

I am looking for a method with jQuery (or plain JS) in which to build a conditional on whether a div has a specific CSS characteristic.
For example, I want jQuery to add position:fixed to an element's CSS when another element is set to display:none, though change back to position:relative on the first element when the second element changes to display:block.
Any ideas?
If your change is event driven you just add the code to your event handlers
so if element one is made hidden by a click - make element 2 position fixed
$("#element_one").click(function(){
$("#element_one").hide();
$("#element_two").css({"position":"fixed"});
})
if you just want to watch elements you will need timers (although I cannot really imagine a scenario where you do not trigger the change by either an event of programaticaly)
watchInterval = setInterval("watchMe()",10)
function watchMe(){
if ($("element_one").is(":hidden") ) {
$("#element_two").css({"position":"fixed"});
}
}
$('#elOne').css('display') == 'none' ? $('#elAnother').css({'position':'fixed'}) : $('#elAnother').css({'position':'relative'});
Would that do the trick?
or perhaps :
$('#elOne').is(':hidden') ? $('#elAnother').css({'position':'fixed'}) : $('#elAnother').css({'position':'relative'});
There's not any nice way of doing this as you cannot "spy" on CSS changes, though jQuery does have a watch plugn which can monitor changes on certain properties. Your best bet is to use getComputedStyle which will get the real CSS values used for any object and act accordingly.

Categories