Tag: javascript events

onChange or other option?

I’m trying to get rid of the save buttons on my websites. I know the most obvious way would be to do a Jquery onChange event. But it seems like it’s going to be a lot of queries on the server. I also thought about doing onBlur, but that would mean the user needs to […]

Creating a Custom Layer Control in Leaflet

I’ve been working on a leaflet map with a number of static layers that can be turned off and on using leaflet’s standard layer control. Recently, I’ve been trying to use the onclick method to run functions to add and remove layers from the map when the user clicks on one of the images in […]

Javascript: Binding via for-loop produces wrong result

I have a number of thumbnails on my website, that are supposed to all bring up the same slide show, but with different slides displayed (by adding and removing a .hidden class). This will be done by function showWork(toShow), with toShow being a number refering to the slide that is suppposed to be visible. The […]

jQuery .select() inside .live() does not work on IE7 and IE8

jQuery(document).ready(function($) { $(‘input[type=”text”]’).live(‘focus’, function() { if (this.value == ‘someValue’) { this.select(); } }); }); The same result with .delegate() and .on(). What am I missing? Any help is appreciated, thank you!

jQuery .one(“click”) on anchor wrapper leads to href not followed

This is a deceptively tricky little bit of HTML/JS that has either me or jQuery thrown for a loop (my money’s on me). It’s demoed in this fiddle. …but here’s the scenario. An anchor is wrapped with a span: <span> the span <a onclick=”alert(‘onclick HTML attritbute fired!’)” href=”http://www.href-attribute- fired.com”>the link</a> wraps the link </span> The […]

Blur event is fired on focused parent element if focused element's child is clicked

I’m stuck with this for hours. I need to create a part of a form where if you click on a select, a checkbox field should popup and if you click anywhere else again, this field should disappear. I would like to do this with focusing the field after clicking on the select, but for […]

How to run a javascript script before the other ones?

Do you know if it is possible to make sure that a Javascript script site is ran first in a webpage? For the context, I’m trying to tag every span before another library (just like cufon) kicks in and messes with the original content. Since it’s not possible to use onLoad() on spans, it’s the […]

JavaScript + event propagation

I have an input box that successfully toggles a hidden div. However, I also want the div to hide when the user clicks anything other than the div itself. How might I do this? html <input id=”inputID” type=”text” readonly /> <div id=”divID”></div> js var divObj = document.getElementById(‘divID’); var inputObj = document.getElementById(‘inputID’); inputObj.addEventListener(‘click’, toggleDiv, false); function […]

Removing event listeners with anonymous function calls in JavaScript

I’m trying to remove an event listener for created span elements where the function called is within a closure. I’ve tried various methods and none seem to work. var MyClass = function () {} MyClass.prototype.addSpan = function (el) { var span = document.createElement(‘span’); span.innerHTML = “Text here”; el.appendChild(span); span.addEventListener(‘click’, (function (obj) { return function () […]

Javascript: ReferenceError

I’m trying to call a function with onchange() in an input form When I check the console in Chrome, the code below returns: ReferenceError: changingNow is not defined In safari, it says ReferenceError: Can’t find variable changingNow Here’s the code: function changingNow() { first_name=document.getElementById(first_name); last_name=document.getElementById(last_name); username=document.getElementById(username); category=document.getElementById(category); if ((first_name!==””)&&(last_name!==””)&&(username!==””)&&(category!=”empty”)) { form1.process.disabled = false; } else […]