Hi,
Is it possible to implement "long press" in JavaScript (or jQuery)? How?
HTML
<a href="" title="">Long press</a>
JavaScript
$("a").mouseup(function(){
// Clear timeout
return false;
}).mousedown(function(){
// Set timeout
return false;
});
Thank you!
...
I'm trying to figure out why my javascript code is not restricting numeric input. Here's the code below:
(function(){
if(window.addEventListener) window.addEventListener("load",init,false);
else if(window.attachEvent) window.attachEvent("onload",init);
function init() {
...
I need a cross browser way of capturing the right mouse click, preventing the default context menu and making it where when the user drags the mouse they can pan the contents of a div. This is largely similar to Google maps in that they will grip the contents and drag to see what they want.
No external libraries please.
I am already...
I'm not quite sure how to describe what I'm looking to do, but I'll do my best.
At the moment I have a parent <div>, with absolutely positioned child <div>s within it, and I'm tracking the mouse pointer location coordinates relative to the element your mouse is over.
At the moment, when I mouse over my child <div>s, I get the mouse loc...
This is not a question about jQuery, but about how jQuery implements such a behaviour.
In jQuery you can do this:
$('#some_link_id').click(function()
{
alert(this.tagName); //displays 'A'
})
could someone explain in general terms (no need you to write code) how do they obtain to pass the event's caller html elments (a link in thi...
I have a html structure like :
<div onmouseover="enable_dropdown(1);" onmouseout="disable_dropdown(1);">
My Groups <a href="#">(view all)</a>
<ul>
<li><strong>Group Name 1</strong></li>
<li><strong>Longer Group Name 2</strong></li>
<li><strong>Longer Group Name 3<...
Is chrome beeping during a "removeAllRanges();" to indicate an error in the code, or just that an action has been taken?
My script does not seem to fail...
...
Hi all, I use jCarouselLite for scrolling text, I use and as the content for scrolling, I need to trigger a javascript event when it reaches at the end of the content(). I need to change the scroll content when it finishes scrolling previous content. I tried adding a call back function but it does'nt work.
This is my code:
$("#scrollD...
i have a calendar and a textbox in my c# asp.net application.
when a user enters a date in the textbox, the selected date in the calendar should become the date entered in the text box. the hard part is that i need to do this in javascript.
what i have now is this:
<asp:TextBox ID="txtDate" runat="server" onchange="javascript: Changed...
hello everyone,
i'm trying to attach an event handler to the load event of a link tag, to execute some code after a stylesheet has loaded.
new_element = document.createElement('link');
new_element.type = 'text/css';
new_element.rel = 'stylesheet';
new_element.href = 'http://domain.tld/file.css';
new_element.addEventListener('load', fun...
Here's the test page I'm using. This version works fine, forwarding to #success:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head>
<script type="text/javascript" src="prototype.js"></script>
</head><body>
<form id='form' method='POST' action='#fail'>
<butt...
Hi guys,
I think I've been too much time looking at this function and just got stuck trying to figure out the nice clean way to do it.
It's a jQuery function that adds a click event to any div that has a click CSS class. When that div.click is clicked it redirects the user to the first link found in it.
function clickabledivs() {
...
I currently have form that checks if a user has unsubmitted changes when they leave the page with a function called through the onunload event. Here's the function:
function saveOnExit() {
var answer = confirm("You are about to leave the page. All unsaved work will be lost. Would you like to save now?");
if (answer) {
doc...
I'm using prototype.js for my web app, and I have everything running on chrome, safari, and firefox. I am now working on IE8 compatibility.
As I've been debugging in IE, I've noticed that there are javascript events for which I have previously set an observer on the window, e.g.
Event.observe(window, eventType, function () {...});
(...
Can i check with jQuery whether the User increased the font size and bind a function to this event, to recalculate some stuff when this happens?
...
Hi everyone,
I am new to JavaScript (only a couple of days of reading a book) and I am stuck on this code snippet. I have looked at it over and over again but cannot seem to figure out why it is not working. I am sure it is something really simple that I have just looked over but I really just need a fresh pair of eyes to look at this....
I just wanted to get the general consensus on which is a better mode of event delegation in JS between bubbling and capturing.
Now I understand that depending on a particular use-case, one might want to use capturing phase over bubbling or vice versa but I want to understand what delegation mode is preferred for most general cases and w...
Hi everyone,
I am new to JavaScript (only a couple of days of reading a book) and I am stuck on this code snippet. I have looked at it over and over again but cannot seem to figure out why it is not working. I am sure it is something really simple that I have just looked over but I really just need a fresh pair of eyes to look at this....
Hi,
I have the following code. And my problem is that when clicking, the event is firing but the argument passed is not the correct one. It is passing the last dynamically created row i.e. dataStructure.length value. Anyone knows a solution how to get around this?
var table = document.getElementById('output'); ...
I have to pass paramter the validateNum javascript function (eg. num1, num2)
if (num1.attachEvent) {
num1.attachEvent("onkeypress", validateNum);
}
How to pass. can i get code sample?
...