document.all vs. document.getElementById
document.all
is a proprietary Microsoft extension to the W3C standard.
getElementById()
is standard - use that.
However, consider if using a js library like jQuery would come in handy. For example, $("#id")
is the jQuery equivalent for getElementById()
. Plus, you can use more than just CSS3 selectors.
What does document.all mean?
document.all() is a non-standard way of accessing DOM elements. It's been deprecated from a few browsers. It gives you access to all sub elements on your document.
document.getElementById() is a standard and fully supported. Each element has a unique id on the document.
Replace document.all with document.getElementById with If Else Statement
I don't understand why the double-quotes appear twice in your <button>
, for example:
<button title=""Void This Payment"" ...
It should be:
<button title="Void This Payment" ...
And there is no "TRUE"
value anywhere in your markup.
The only way your condition can work is if you add a value="TRUE"
attribute to the button, for example:
<button title="Void This Payment" value="TRUE" ...
With these changes, it should work.
document.documentElement vs document.all
document.all
is a proprietary Microsoft extension to the W3C-standard.
It's an old function and should not be used anymore!
rfc document.all vs. document.getElementById
what's the difference between $('#') and document.getElementById()?
getElementById
returns a DOM element object.
$
returns a jQuery object. Passing it a string containing an id selector causes it to populate the jQuery object with a DOM element object.
val
is a jQuery method, not a DOM element method.
are document.all and document.layers obsolete now
Yes, they are obsolete.
The document.all
collection is specific to Internet Explorer. The document.layers
collection was specific to Netscape. Neither is in the standards.
Today we use document.getElementById
instead.
See also: https://developer.mozilla.org/en-US/docs/Mozilla_Web_Developer_FAQ#JavaScript_doesn.E2.80.99t_work.21_Why.3F
document.object Vs. document.getElementById()
document.forms
is a very old method of accessing stuff, along with document.images
and document.all
, and possibly a few others that I don't remember.
The number one flaw in accessing document.forms[1]
is simple: what if another form is added to the page, before the target one? Suddenly you have to search through all your code for references to anything, and change them.
This is where IDs come in. By only allowing one of each ID on a page, getElementById
can accurately retrieve it, every time, without caring about what happens to the document in the meantime. The only change that matters is the element being removed altogether.
Related Topics
Converting .Net Datetime to JSON
How to Set Locale in Datepipe in Angular 2
New Es6 Syntax for Importing Commonjs/Amd Modules I.E. 'Import Foo = Require('Foo')'
Differencebetween JavaScript Promises and Async Await
Make Browser Window Blink in Task Bar
Uncaught Typeerror: Illegal Invocation in JavaScript
Alternative to a Million If Statements
How to Replace Remapcolums with Remapcolumnsbyname in Free Jqgrid
How to Create a Dialog with "Ok" and "Cancel" Options
Jquery Selectors on Custom Data Attributes Using HTML5
Chrome, JavaScript, Window.Open in New Tab
Failed to Execute 'Postmessage' on 'Domwindow': Https://Www.Youtube.Com !== Http://Localhost:9000
How to Parse JSON to Receive a Date Object in JavaScript
Adding Custom Functions into Array.Prototype