Welcome To Snipplr
Everyone's Recent Snippets Tagged DOM
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
A simple, non-recursive function that I use to return the first element with an ID that contains a certain ID string.
Sometimes, APS.NET appends the Naming Container ID to the IDs of controls, and in instances where the ClientID of a control you wa...
0
515
posted 14 years ago by erintechspired
Gets the outerHTML of a DOMElement. For a more optimal version check the URL.
0
979
posted 14 years ago by Znupi
This example uses file_get_contents to retrieve remote HTML. From there, we can parse through it using PHP5's DOMDocument and DOMXpath. XPath Queries are easy to create using the Firefox extension "XPather"
3
1878
posted 15 years ago by adamcoulombe
Go to page, then place code in address bar and generated code will be shown in new window.
1
986
posted 15 years ago by bionic
I just noticed in Firefox 3.5.2 that setting `disabled = true` for a focused text input seems to make it impossible to re-focus after setting `disabled = false`. The solution is to blur it before disabling.
0
1269
posted 15 years ago by cyberhobo
Usage:
//any element
window.onload = function(){
focusFirstInput();
}
or
// form elements under 'content-body'
window.onload = function(){
focusFirstInput('content-body');
}
0
793
posted 15 years ago by neoprolog
If you want to trigger an event on an matched element and that element may be introduced into the DOM from an Ajax request, you can still match against it by using the livequery plugin and the following code.
1
718
posted 15 years ago by Meander365
Manipulates XML nodes using PHP's Dom library. Includes XPath navigation, child manipulation, and deletion of current document.
0
735
posted 15 years ago by mikeevans
Memory leakage in IE6/7 if the event handlers are not purged before deleting an element.
0
785
posted 15 years ago by iTony
<a href="javascript:(function(){var%20ids=[];jQuery('*').each(function(){if(this.id&&this.id!==''){if(ids[this.id]){console.log('duplicate%20id%20found:%20'+this.id,this,ids[this.id])}else{ids[this.id]=this}}});})();">Find duplicate IDs</a> (drag me...
1
963
posted 15 years ago by krunkosaurus
Example:
Add the following ccs '@media print { body { font-size: 12pt } }' to the document.
0
1001
posted 15 years ago by HubertGaulin
fix for IE, adds getComputedStyle method for the object window and getPropertyValue method for the object, which returns getComputedStyle
1
4162
posted 15 years ago by Jman
Great little snippit to add a <tr> to the bottom of a table. Note the use of the context in the jQuery e.g var n = $('tr:last td', this).length; Will have to use this in the future, very good to know!
4
1707
posted 15 years ago by 1man
A little bit of browser detection and some functions to get the viewport height and width, crossbrowser.
1
1599
posted 15 years ago by ShiftyP
It is utterly annoying when DOM event handler exceptions fail silently with Firebug. This package fixes this common problem.
0
736
posted 15 years ago by miohtama
This function will sort an array of DOM elements in order of the DOM position. Useful when using calls such as $$("img.L,img.M") which doesn;t return a sorted element array.
It uses prototype but you can replace the Prototype.Browser stuff with a...
0
1099
posted 16 years ago by kouphax
Use sample:
var inputTxt = getElementsByAttr('input', 'type', 'text');
1
687
posted 16 years ago by kcmr
Determines if a given element is visible, by checking a variety of things. Will work for CSS or inline style declarations of visible:hidden or display: none. Will check if it's inside of an invisible element, as well.
3
1004
posted 16 years ago by TALlama
This is a little trick I came up with to add outerHTML functionality in Firefox. For those who aren't familiar with outerHTML, it is an IE addition to the DOM that will return the element's HTML PLUS it's innerHTML. Is it really needed? No, but it ca...
1
1501
posted 16 years ago by localhorst