Skip to content
Advertisement

Select Element By CSS style (all with given style)

Is there a way to select all elements that have a given style using JavaScript? Eg, I want all absolutely positioned elements on a page. I would assume it is easier to find elements by style where the style is explicitly declared: the style is non-inherited (such as positioning) the style is not the default (as would be position:static). Am

How can I share code between Node.js and the browser?

I am creating a small application with a JavaScript client (run in the browser) and a Node.js server, communicating using WebSocket. I would like to share code between the client and the server. I have only just started with Node.js and my knowledge of modern JavaScript is a little rusty, to say the least. So I am still getting my

Detect changes in the DOM

I want to execute a function when some div or input are added to the html. Is this possible? For example, a text input is added, then the function should be called. Answer 2015 update, new MutationObserver is supported by modern browsers: Chrome 18+, Firefox 14+, IE 11+, Safari 6+ If you need to support older ones, you may try

JavaScript – Get all but last item in array

This is my code: I want linkElementLink.href to grab everything but the last item in the array. Right now it is broken, and the item before it gets the second-to-last item. Answer Use pathname in preference to href to retrieve only the path part of the link. Otherwise you’ll get unexpected results if there is a ?query or #fragment suffix,

Accessing the content of other tabs in a browser

I am using Mozilla Firefox and I am trying to figure out a way to access the content of other tabs in the same window using JavaScript and the DOM (I am open to other techniques if exist). E.g., I want to run JavaScript code in tab1 which can find the title of some other tab. Basically I need this

why can’t i set window.onload in IE8?

I have the following function, which works fine in Firefox, but will do nothing in IE8 I want to open a webpage and immediately open the print dialogue. Answer If you have the hand on the page at url, place the call there. In the HTML, at the end of the BODY tag. Add a SCRIPT tag with your call

Advertisement