dom « element « Javascript HTML CSS Q&A

Home
Javascript HTML CSS Q&A
1.animation
2.audio
3.background
4.browser
5.button
6.canvas
7.checkbox
8.Cookie
9.Development
10.DIV
11.dom
12.dropdown
13.editor
14.element
15.Event
16.Firefox
17.flash
18.font
19.Form
20.frame
21.hide
22.hyperlink
23.IE
24.iframe
25.image
26.innerHTML
27.json
28.layout
29.Library
30.localStorage
31.Menu
32.mobile
33.onclick
34.popup
35.Render
36.scroll
37.scrollbar
38.svg
39.tab
40.table
41.tag
42.text
43.TextArea
44.TextBox
45.validation
46.video
47.window
48.xml
Javascript HTML CSS Q&A » element » dom 

1. How do I programatically set the value of a select box element using javascript?    stackoverflow.com

I have the following HTML select element:

<select id="leaveCode" name="leaveCode">
  <option value="10">Annual Leave</option>
  <option value="11">Medical Leave</option>
  <option value="14">Long Service</option>
  <option value="17">Leave Without Pay</option>
</select>
Using a javascript function with the ...

2. How can javascript determine the type of an html element?    stackoverflow.com

I feel like this should be really easy to do, but I'm stumped. I need a way for Javascript to determine the type of an HTML element. It has the id, ...

3. How to tell if a DOM element is displayed?    stackoverflow.com

This is not to be confused with "How to tell if a DOM element is visible?" I want to determine if a given DOM element is visible on the page. E.g. if ...

4. Correct element.getElementsByTagName() implementation    stackoverflow.com

//EDIT My issue was related to something else, I thought the implementation was incorrect but it actually works, thanks for the confirmation. Looked in jQuery and prototypejs, can't seem to find the ...

5. Get next/previous element using Javascript    stackoverflow.com

How do I get the next element in html using javascript? Suppose I have three divs and I get a reference to one in js code, I want to get which is ...

6. Counting web page fully loaded elements in javascript    stackoverflow.com

Is there any way to find out that how many elements are going to be loaded in a webpage via javascript?
for example, I'm going to show the visitor something ...

7. How can I count text lines inside an DOM element? Can I?    stackoverflow.com

I'm wondering if there's a way to count lines inside a div for example. Say we have a div like so:

<div id="content">hello how are you?</div>
Depending on many factors, the div can ...

8. Subclassing from (extending) an HTML element?    stackoverflow.com

I'd love it if I could make my own class that extended an HTML element class, e.g. HTMLDivElement or HTMLImageElement. Assuming the standard inheritance pattern:

// class A:

function ClassA(foo) {
    ...

9. plain javascript code to highlight an html element    stackoverflow.com

to debug some javascript code, I am looking for javascript code (preferably just js, without libraries and dependencies) that can highlight a div or span (probably by putting over it a ...

10. Is there a good way to attach javascript objects to HTML elements?    stackoverflow.com

I want to associate a javascript object with an HTML element. Is there a simple way to do this. I noticed in the HTML DOM (http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html) defines a setAttribute method ...

11. element onkeydown keycode javascript    stackoverflow.com

Hi
I am using this code snippet to add KeyDown event handler to any element in the html form

for(var i=0;i<ele.length;i++)
{
    ele[i].onkeydown = function()
    {
   ...

12. How to attach a "pointer" to DOM element to a lightbox instead of copying it?    stackoverflow.com

I have a complex input form within a PHP based web application. To structure it a bit, I introduced "Multifaceted lightbox" to let parts of the form - named ...

13. How to get the HTML for a DOM element in javascript    stackoverflow.com

Imagine I have the following HTML:

<div><span><b>This is in bold</b></span></div>
I want to get the HTML for the div, including the div itself. Element.innerHTML only returns:
<span>...</span>
Any ideas? Thanks

14. Change or swap the CSS of multiple HTML elements at once    stackoverflow.com

I have about 100 <span class="foo">, 100 <span class="bar"> and 100 <span class="baz"> tags in my document. I need to implement the following operations in JavaScript:

  • Change the background all foos to ...

15. add element to the DOM with JS    stackoverflow.com

I want add element with JS. I have code:

var collection = document.getElementsByTagName('body');
var a = document.createElement('div');
        a.innerHTML = 'some text';
      ...

16. typeof for html plugin elements    stackoverflow.com

When using ECMAScripts typeof on plugin elements (i.e. embed or object), Safari & FireFox return "function":

typeof(window.document['myPlugin']) // "function"
This can't be influenced on the plugin side, as the browser doesn't call the ...

17. How to identify HTML elements (in javascript) in a browser agnostic fashion    stackoverflow.com

I need to identify all html elements on a page in a browser agnostic fashion. What I am basically doing is using mouse events to record clicks on the page. ...

18. How to overwrite html element from javascript?    stackoverflow.com

I have HTML page with some HTML element with ID="logo". I need to create JS script (with no external libs calls) that will overwrite that html element with other HTML element ...

19. How do I loop through elements inside a div?    stackoverflow.com

I have to make a custom function for search/replace text, because firefox counts text nodes differently than IE, Google Chrome, etc.. I am trying to use this code, that I saw at ...

20. Html object container    stackoverflow.com

Does someone knows how can I change the container for my drop down box? I have 3 "TD" tags and I would like to move the drop down between them, using client ...

21. How to access child div elements under a given condition with javascript?    stackoverflow.com

My main question is to calculate the last alert message, but any other information is also welcome. I am trying to learn javascript (to use with greasemonkey later), but I am struggling ...

22. How to swap HTML elements in javascript?    stackoverflow.com

I am using classic Javascript for DOM scripting, i have a set of DIV's in a container DIV. On click event of child DIV's, i want that the child DIV which has ...

23. Adding new elements into DOM using JavaScript (appendChild)    stackoverflow.com

I sometimes need to add elements (such as a new link and image) to an existing HTML page, but I only have access to a small portion of the page far ...

24. Possible to determine if an html element is self-closed or not?    stackoverflow.com

I started working on an experimental project tonight. I've realized that I need to determine if a group of selected nodes are self closing or not. For example, suppose I query the ...

25. Unique identifier for HTML elements    stackoverflow.com

Besides of the ID, if you say, you want a unique identifier for an HTML element (let say a div). I browsed the DOM for something (like a number or string) that ...

26. Is there a way to create your own HTML element?    stackoverflow.com

Is there a way to create your own HTML element? I want to make a specially designed check box. I imagine such a thing would be done in JavaScript. Something akin to ...

27. Any clever ways to serialize an HTML element? - Javascript    stackoverflow.com

I'm trying to store a reference of an HTML tag for later reuse. e.g. If I click on a div and save a pointer to that div within Javascript, will there be ...

28. Moving a DIV element to bottom of parent (as last child)    stackoverflow.com

I'm trying to create a continually rotating banner for the top of the homepage of a site I'm developing. The best way that I can figure to keep it constantly in ...

29. Adding HTML elements with JavaScript    stackoverflow.com

So, if I have HTML like this:

<div id='div'>
  <a>Link</a>

  <span>text</span>
</div>
How can I use JavaScript to add an HTML element where that blank line is?

30. finding location of HTML elements with javascript & offsettop    stackoverflow.com

I'm trying to find the location of an element on the screen using javascript. This is what I'm doing.

function locateTargets(){
    var targets = document.getElementsByTagName("span");
    for(var ...

31. How do I get DOM elements of which tagnames start with a prefix    stackoverflow.com

Using javascript, how do I get all DOM elements that start with a certain prefix like <prefix:suffix> Code example:

<div>
    <foo:bar1>hello</foo:bar1>
</div>
<foo:bar2>world</foo:bar2>
But, without looping through ALL elements (for performance reasons)? Thanks, Ran ...

32. Get the dom element that represents the javascript tag where the code that is running is embebed    stackoverflow.com

Example:

<script>
// I want to have the dom element of the script tag that is holding the code that goes here
</script>
If I do:
<script>
alert(this)
</script>
this is the window. I want to access the script tag ...

33. How to use getElementsByTagName() to find all nested elements?    stackoverflow.com

I have the following HTML:

<html>
  <head><title>Title</title></head>
  <body>
    <div id='div2'>
      <a href='#'>1</a>
      <div id='div1'>
    ...

34. Javascript html element search and highlight    stackoverflow.com

I want to search a webpage for elements by tag name such a <p> or <body> or by class id and then highlight them. I want to do this using 3 ...

35. Formatting of elements inside a div element without effect of inherited css    stackoverflow.com

I'm showing a popup as a fixed div in random websites. I need the content of the div to not be effected by the formatting of the page it resides in. ...

36. How to swap a disabled option DOM element to enabled?    stackoverflow.com

I have a list with enabled and disabled option. I do know how to disable an option element but what I don't know how to enable it again.

<select size="1" id="x">
 ...

37. Is it possible to show a html element already on a page a second time without copying it?    stackoverflow.com

I have a page with a hidden form containing several divs.

<form action="...">
    <div>
        <input id="menubar_open_article_bid" name="bid" onfocus="this.select();" onkeyup="do_v(); type="text">
   ...

38. How do I programatically set the values (plural) of a multi-select box element using javascript?    stackoverflow.com

I have a form like this:

<form action="/cgi-bin/cgi_info.py" method="POST">
  <select id="faults" class="multiselect" multiple="multiple" name="faults[]">
    <option>Big nose
    <option>Big feet
    <option>Wrinkly nose
   ...

39. Is it possible to determine when a dom element has come into view?    stackoverflow.com

Is it possible to determine when a dom element has come into view ? I would like an event to be raised when an element (e.g div, image) has come into the ...

40. How to place caret inside an empty DOM Element Node    stackoverflow.com

How can I place the caret (collapsed range) inside an empty element node. This code is supposed to work, but it doesnt.

node = document.getElementById('some-empty-strong-node')
range = document.createRange()
range.selectNodeContents(node)
window.getSelection().addRange(range)
Trying other tricks like adding an ...

41. Serialize DOM elements including all CSS properties    stackoverflow.com

I am developing a online website design system like yola.com. I want to get a list of applied CSS properties with their values to any DOM element. For example, I have ...

42. Get element by tag name shorthand    stackoverflow.com

I don't know what it's called, but I know that there's a way to get elements based on their tags without getElementsByTagName. It returns the same thing, but it's shorter and ...

43. is there a tool to capture all DOM webpage elements generated by browser-side javascript as html, for a full page html archive?    stackoverflow.com

if a whole bunch of elements gets generated in my browser by javascript (using JSON data or just out of thin air) I am not able to fully archive such a ...

44. Too Many DOM Elements    stackoverflow.com

I am building a one page webapp and it's starting to get pretty big. There are several components to the app, each one meticulously styled. On average the app has a ...

45. Is there any way to find out what javascript is affecting what element?    stackoverflow.com

I've got some elements in the DOM that are being made visible by some javascript, but I can't find what javascript is affecting those elements? Like you can use firebug/chrome to ...

46. meta property is undefined    stackoverflow.com

i have some code which takes in a html using ajax and after which it's meta tags are retrieved.

if (request.readyState == 4) { 
    var html_text = request.responseText; ...

47. javascript substitute DOM element    stackoverflow.com

I would like to do something like:

var htmlcode = '<div>testing</div>';
document.getElementById('initDiv').html = htmlcode;
kinda like using innerHTML but replacing the element itself. Can someone help me please? thanks

48. Javascript namespaced html elements    stackoverflow.com

I don't know exactly how to post this question, so, please, bare with me: I am writing something academic where I have namespaced html elements like:

<ns:LinkList id="sitesuteis" cssClass="classone">
     ...

49. Javascript - Accessing element values? DOM tree?    stackoverflow.com

I have a form with multiple text input fields and sub-forms. Is there a way to access everything based on how it appears in the DOM tree? In other words, if I ...

50. JavaScript Cross-Browser PerformClick on a DOM Element    stackoverflow.com

Is there a vanilla JavaScript cross-browser function available that is able to trigger a click event on a DOM element (including non-form elements)?

51. Find out if an element is obscured via JavaScript    stackoverflow.com

Is there a way to find out if an element is obscured by another element that is not a child of the first one? Because I have a menu that I ...

52. Which is quicker - on the fly html or creating elements with javascript?    stackoverflow.com

object.innerHTML = "<div class='panel'>foo |</div>"
or
panel = document.createElement ("div");
panel.setAttribute ("class", "panel");
panel.innerHTML = "foo |";
object.appendChild (panel);
Say I'm creating a lot of divs on the fly (around a hundred or so), each with ...

53. Client, editing dynamically the value of the dom elements such as

Javascript    stackoverflow.com

Are there relatively simple ways to implement this:

  • I have a div element with position absolute
  • I am doing double click on it
  • Now focus is on this div, there is a caret appeared
  • I ...

54. Get first and last word in element's text    stackoverflow.com

In JavaScript, how can I get the first and last words from an element's text? For example:

<div class="content">this is a test</div>// output 'this' 'test'
<p>This is another test</p>// output 'this' 'test'
How can ...

55. Changing the order of elements using JavaSript    stackoverflow.com

I am creating a website of floating width. The users use screens from full HD resolution to some 600px on smart phones it seems a pretty good idea. This brings up ...

56. Adding an img element to a div with javascript    stackoverflow.com

I am trying to add an img to the placehere div using JavaScript, however I am having no luck. Can anyone give me a hand with my code?

<html>
<script type="text/javascript">
var elem = ...

57. html dom for td element    stackoverflow.com

How do I call the td element of a html table from the dom? document.getElementById("exampleTable").childNodes[] Should give you all of the tr elements, but how do you go two levels down? ...

58. Creating element in browser extension inherits browser css?    stackoverflow.com

I'm working on a firefox extension and one of the things I need to do is adding an element to the dom. I have no problem with this, except that I ...

59. How do I include all children of a DOM element to be dragged using the Sortable plugin for MooTools?    stackoverflow.com

I am using mootools-more.1817.js...this is my HTML structure:

<ul id="categories">
  <div id="admin">Admin Controls</div>
    <li class="selected"><a href="#">Test</a>
        <ul>
   ...

60. problem in adding div element (DOM)    codingforums.com

function addPrivate() { var root = document.getElementById('registration'); var label1 = document.createElement('label'); label1.appendChild(document.createTextNode('First Name: ')); var label2 = document.createElement('label'); label2.appendChild(document.createTextNode('Last Name: ')); var label3 = document.createElement('label'); label3.appendChild(document.createTextNode('Address*: ')); var label4 = document.createElement('label'); label4.appendChild(document.createTextNode('Profession: ')); var div = document.createElement('div'); var input1 = createElement('input'); input1.type='text'; input1.name='fname'; var input2 = createElement('input'); input2.type='text'; input2.name='lname'; var input3 = createElement('input'); input3.type='text'; input3.name='address'; var input4 = createElement('input'); input4.type='text'; input4.name='profession'; ...

61. Generate a DIV for each DOM element ??    forums.devshed.com

__________________ Three gigs for the secretaries fair Seven gigs for the system source Nine gigs for the coders in smoky lairs One disk to rule them all, one disk to bind them One disk to hold the files, and in the darkness grind'em --------------------------------------------------- It is by caffeine alone that I set my mind in motion. It is by the beans ...

62. Created DOM elements and CSS    sitepoint.com

63. DOM created external css link element messes up clientHeight and clientWidth in Gecko    sitepoint.com

Hello, In both Firefox and Netscape. If I create an external css ref using document.createElement('link'); (I also set the rel,type, and href props) the elements it specified in the external.css with a width of 100% and a height of 100% no longer give the proper clientWidth and clientHeight reading. Instead clientWidth and clientHeight match that of offsetWidth and offsetHeight (which doesnt ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.