jquery-events

JQuery show/hide when hover

蹲街弑〆低调 提交于 2019-11-27 20:29:36
I have three links, Cat, Dog, Snakes. When I hover over each, the content relating to each link should change. So if i hover over cat, then cat content will appear, if i hover over dog the cat content will smoothly disappear and the dog content will appear... and so on. Links are: Dog Cat Snake <div> <span style="display:none;"> Cat Content</span> <span style="display:none;"> Dog Content</span> <span style="display:none;"> Snake Content</span> </div> How do I get this to be full blown working, with some smooth fading? Vivek ('.cat').hover( function () { $(this).show(); }, function () { $(this)

Drop event not firing in chrome

无人久伴 提交于 2019-11-27 19:33:59
It seems the drop event is not triggering when I would expect. I assume that the drop event fires when an element that is being dragged is releases above the target element, but this doesn't seem to the the case. What am I misunderstanding? http://jsfiddle.net/LntTL/ $('.drop').on('drop dragdrop',function(){ alert('dropped'); }); $('.drop').on('dragenter',function(){ $(this).html('drop now').css('background','blue'); }) $('.drop').on('dragleave',function(){ $(this).html('drop here').css('background','red'); }) iamchris In order to have the drop event occur on a div element, you must cancel the

jQuery .on() method doesn't see new elements

五迷三道 提交于 2019-11-27 12:33:51
I'm getting a JSON element and building a list from its items like this: getTitles: function(data) { data = data || {}; var list = []; $.getJSON( '/titles', data, function(data) { $.each(data.data, function(key, val) { list.push( '<li><a href="'+ val.href +'">'+ val.title +'</a><span class="count">'+ val.count +'</span></li>' ) }); $('#title-items').html(list.join('')); } ); } And I'm binding click event for a elements like this: $('a').on('click', function(e) { alert('clicked'); e.preventDefault(); }); Old a elements shows alert but new ones follow URL. Event handler doesn't work for new ones

jQuery watch for domElement changes?

删除回忆录丶 提交于 2019-11-27 11:54:53
I have an ajax callback which injects html markup into a footer div. What I can't figure out is how to create a way to monitor the div for when it's contents change. Placing the layout logic I'm trying to create in the callback isn't an option as each method (callback and my layout div handler) shouldn't know about the other. Ideally I'd like to see some kind of event handler akin to $('#myDiv').ContentsChanged(function() {...}) or $('#myDiv').TriggerWhenContentExists( function() {...}) I found a plugin called watch and an improved version of that plugin but could never get either to trigger.

Trigger events in iframe's parent window

限于喜欢 提交于 2019-11-27 10:53:46
问题 Why is the following not working: //iframe: window.parent.$(document).trigger('complete'); //parent window: $(document).bind('complete', function(){ alert('Complete'); }); while the following IS working: //iframe: window.parent.$('body').trigger('complete'); //parent window: $('body').bind('complete', function(){ alert('Complete'); }); ? 回答1: The way events are tracked, you can only trigger or receive events on the same document. try window.parent.$(window.parent.document).trigger('complete')

Twitter Bootstrap onclick event on buttons-radio

你离开我真会死。 提交于 2019-11-27 10:25:22
问题 I have a Twitter Bootstrap buttons-radio and hook an onclick event to it. But how do I check which of the buttons that got triggered? My first thought was to simply check for the class 'active', but this should create a race condition (result depends on whether the Twitter Bootstrap event or my own onclick event is handled first). 回答1: This is a really annoying one. What I ended up using is this: First, create a group of simple buttons with no data-toggle attribute. <div id="selector" class=

Multiple JS event handlers on single element

為{幸葍}努か 提交于 2019-11-27 10:01:27
问题 I am working with an existing web app, in the app there are a variety of submit buttons on different forms, some using regular http post, some defining an onClick function, and some binding a js event handler to the button using a class on the element. What I want to do, is bind another event handler to these buttons by just adding a class to the buttons, but what I want to determine is will the new event handler be guaranteed to be executed, or could one of the form submit actions happen

jQuery/js/html5 change page content when keyboard is visible on mobile devices [duplicate]

我只是一个虾纸丫 提交于 2019-11-27 09:53:27
问题 Possible Duplicate: iPad Web App: Detect Virtual Keyboard Using JavaScript in Safari? I'm building a mobile version for a website, and I'm interested if I can create using jQuery/js/html5 or any other technology the same split screen effect that can be made on mobile apps when virtual keyboard is visible. For example if a user enters my webpage and clicks on an input text field, the virtual keyboard is showed and the browser automatically zooms to the area where the input text field is. What

Using Firefox, how can I monitor all events that are fired?

耗尽温柔 提交于 2019-11-27 09:21:07
问题 I'm trying to debug a web page that makes heavy use of events, and so I need to monitor all events that are fired. Most of the events are bound using jQuery. Hence, it would be particularly useful if there was a way to specifically monitor only those events. 回答1: Of course you can do just fine with Firebug, the console and the scripts tab where you can add breakpoints and watches, but you want to do it smarter / easier obviously. There is a neat Firebug plugin called EventBug that just logs

How to call function when user Allows or Denies access to “Physical Location”?

本小妞迷上赌 提交于 2019-11-27 06:12:00
问题 My application is powered by jQuery mobile and uses geolocation. After my application attempts to get the user's location, the (Chrome) browser prompts the user: Example.com wants to track your physical location [allow] [deny] My goal is: If the user clicks "Allow", function 1 is called (location is used by app). If the user clicks "Deny", function 2 is called (address form appears). How can I bind a function to the event that occurs (if any) when the user clicks the "Allow" or "Deny" button?