getelementbyid

Diference between getElementById and jquery $('#smth')

假装没事ソ 提交于 2019-11-28 21:13:05
What's the difference between classic Javascript code: document.getElementById('theID') and the jQuery version: $('#theID') document.getElementById returns a DOM object. This is the browser's native way of thinking about an element in the page. It has various methods and properties. These can be a little clunky to use. The jQuery object (created by the $ method) is a wrapper around a DOM element or a set of DOM elements. The normal properties and methods are not available; you get a selection of different methods that make the process of DOM manipulation more intuitive. The difference is more

vue.js 'document.getElementById' shorthand

↘锁芯ラ 提交于 2019-11-28 19:09:15
Does vue.js have a shorthand for document.getElementById('#id') like JQuery's $('#id') ? If so, where is the reference for this in the docs so I can locate other information? 胡亚雄 Theres no shorthand way in vue 2. Jeff's method seems already deprecated in vue 2. Heres another way u can achieve your goal. var app = new Vue({ el:'#app', methods: { showMyDiv() { console.log(this.$refs.myDiv); } } }); <script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script> <div id='app'> <div id="myDiv" ref="myDiv"></div> <button v-on:click="showMyDiv" >Show My Div</button> </div> Jeff You can

Exception 0x800A01B6 using getElementById after the first load

戏子无情 提交于 2019-11-28 11:40:43
问题 I have created a ribbon for Powerpoint with visual studio XML ribbon. This ribbon has a button that, simplifying, does this: opens an IE browser search an element (hiddenfield) in the code by his id get the value of this element Print the value in the actual slide It works correctly the first time I click the button of my ribbon, but it throws an Exception 0x800A01B6 the following times I click the button. This is the code executed when I click the button: Dim oType As Type = Type

Javascript: access DOM elements without getElementById [duplicate]

北慕城南 提交于 2019-11-28 09:49:52
问题 This question already has answers here : Is there a spec that the id of elements should be made global variable? (5 answers) Closed 2 years ago . Below is some sample code. <body> <div id="wrapper" class="access"> <form id="test"> <input id="password"></input> <input type="submit"></input> </form> </div> <script> console.log(password); alert(wrapper.className); </script> </body> The console log returns the DOM element with id password . The alert is "alert". It works in normal code as well, e

C# get element by name

落花浮王杯 提交于 2019-11-28 08:18:39
问题 Soo ive figured out how to get element by id, but i dont know how i can get element by name Here is my code: private void SendData() { webBrowser1.Document.GetElementById("textfield1").SetAttribute("value", textBox1.Text); webBrowser1.Document.GetElementById("textfield2").SetAttribute("value", textBox1.Text); } The problem is in my html code only textfield1 is a id but textfield2 is name soo i want to figure out how to get textfield2 Here is my html code: <html> <input type="text" id=

document.getElementById('btnid').disabled is not working in firefox and chrome

半城伤御伤魂 提交于 2019-11-28 06:57:22
I'm using JavaScript for disabling a button. Works fine in IE but not in FireFox and chrome, here is the script what I'm working on: function disbtn(e) { if ( someCondition == true ) { document.getElementById('btn1').disabled = true; } else { document.getElementById('btn1').disabled = false; } And in my html I have: <input type="button" id="btn1" value="submit" /> use setAttribute() and removeAttribute() function disbtn(e) { if ( someCondition == true ) { document.getElementById('btn1').setAttribute("disabled","disabled"); } else { document.getElementById('btn1').removeAttribute("disabled"); }

Javascript getElementById lookups - hash map or recursive tree traversal?

一个人想着一个人 提交于 2019-11-28 05:18:16
Does the DOM have a hash-table of elements whose keys are the elements' ids? I want to know if document.getElementById looks up a hash table or traverses the entire tree. Is this behavior different across browsers? T.J. Crowder Implementations are free to do whatever they like, but since id is defined as a unique value, it would seem sensible to use a hash map or similiar lookup mechanism rather than traversal. What seems sensible from the outside, though, may not be when you get into the plumbing of building a complex web browser with many (sometimes conflicting) imperatives. I did an easy

Powershell, ie9 and getElementById

こ雲淡風輕ζ 提交于 2019-11-28 01:19:42
I use successfully a script for web automation from this site: heise web automation I know it is in german, but perhaps someone can help. The important part of the e-plus website: <tr> <td class="td1">Benutzername:</td> <td class="space"><img src="/img/c.gif" alt="" /></td> <td class="td2"><input type="text" id="IDToken1OL" name="IDToken1" onfocus="setToken(this)" onblur="getToken(this)" value="Benutzername" /></td> </tr> <tr> <td class="td1">Passwort:</td> <td class="space"><img src="/img/c.gif" alt="" /></td> <td class="td2"><input type="password" id="IDToken2OL" name="IDToken2" onfocus=

Set document.getElementById to variable

拟墨画扇 提交于 2019-11-28 01:09:23
The following works: $ = document.form; x = $.name.value; This doesn't: $ = document.getElementById; x = $("id").value; Any ideas on why this doesn't work or how to make it so? The value of this depends on how you call the function. When you call document.getElementById then getElementById gets this === document . When you copy getElementById to a different variable and then call it as $ then this === window (because window is the default variable). This then causes it to look for the id in the window object instead of in the document object, and that fails horribly because windows aren't

Inherited CSS Values via Javascript

主宰稳场 提交于 2019-11-28 01:01:05
On my page I am changing some css styles via javascript. When I try and pull a value that has been inherited - it comes up blank. Consider the following: .Sliding { display: none; overflow: hidden; } .Sliding #FilterBox { height: 185px; background-color: Fuchsia; } And the html: <div class="Sliding" id="FilterBox"> <h3>Test Form</h3> This is a test/<br /> 12345 </div> If I look at the element ' document.getElementById(objname).style.display ' its blank? How can I read the display value via via javascript? You'll want to use getComputedStyle . The .style property is a means of accessing and