Skip to content
Advertisement

Tag: dom-events

Cannot read property length of undefined

I am trying to simply check if I have an empty input text box but I get this error when I run this in Chrome: Uncaught TypeError: Cannot read property ‘length’ of undefined. Here is how I go about doing it. I check for DOM readiness and then call the function: Answer The id of the input seems is not

window.close() after page redirect

I am on a work intranet only having to support IE8. I am creating a page called “watch video” which (as the name suggests) serves a video to the client. A page linking to a video will open this page in a popup with the link in the url. The person accessing the video (and a datetime stamp) is then

Javascript showing in dollars

How would I display JavaScript output numbers in dollar format? I.E. $20.00 then $2,000.00 when the number gets larger. Ok so sample code. Answer Here’s the function that I use.. Basically the same as @Senad’s except it adds commas:

How to get Events associated with DOM elements?

I have an HTML document. It is possible to get the events associated with every Element in a particular FORM element in the document using JavaScript. This way I can get jth element in ith form, But can I get the event associated with the element. There can be any number of elements in a form. I am using IE

Simple version of jQuery live function

Is it possible to get anywhere a pure Javascript function for event handler with similar functionality as jQuery’s live() ? I need to have the ability to attach events to objects not yet created but both jquery-livequery as well as jquery-events sources are not useful due to dependencies on jQuery core. Answer Event delegation is quite simple. Take this example:

Get Line co-ordinates in Javascript

I am drawing lines using Canvas (HTML 5), since lines/shapes are not stored as objects in Canvas, I cannot attach unique events to it (eg onmouseclick) I wish to attach a onmouseover event to a line, is it possible by getting to know if the mouse if over a particular line (using its 2 X and 2 Y co-ordinates) in

Advertisement