jquery-events

JQuery Event for user pressing enter in a textbox?

霸气de小男生 提交于 2019-11-30 10:03:27
问题 Is there any event in Jquery that's triggered only if the user hits the enter button in a textbox? Or any plugin that can be added to include this? If not, how would I write a quick plugin that would do this? 回答1: You can wire up your own custom event $('textarea').bind("enterKey",function(e){ //do stuff here }); $('textarea').keyup(function(e){ if(e.keyCode == 13) { $(this).trigger("enterKey"); } }); http://jsfiddle.net/x7HVQ/ 回答2: $('#textbox').on('keypress', function (e) { if(e.which ===

How do I attach a jQuery event handler to a YouTube movie?

孤街浪徒 提交于 2019-11-30 07:42:58
[EDIT: Sorry to those who already answered -- in my sleep-deprived state, I forgot that this particular situation is a YouTube movie, not the JW FLV player. I can see that there is more extensive documentation on interacting with YouTube movies, so I will pursue that, but any more information is also welcome] I am using embedded YouTube videos in a collection of divs that are being rotated by using the jQuery cycle plugin ( http://malsup.com/jquery/cycle/ ). I would like the cycle to stop when I click on one of the movies to start it playing, but I can't figure out how to attach a jQuery event

Turn the Tooltip Bootstrap functionality off

此生再无相见时 提交于 2019-11-30 00:19:51
According the documentation is is possible to turn off the functionality just doing $('body').off('.alert.data-api') . In the case of tooltip I tried the following from js console $('body').off('.tooltip.data-api') but it does not disable the tooltip on bottons. Any hints how to precede? Jasny - Arnold Daniels You can't disable tooltips that way because it has no event listener on the body. Instead, you can disable the tooltips themselves using the code below. $('[rel=tooltip]').tooltip() // Init tooltips $('[rel=tooltip]').tooltip('disable') // Disable tooltips $('[rel=tooltip]').tooltip(

Detect a window width change but not a height change

余生长醉 提交于 2019-11-29 23:39:58
I'm using the .resize() function to detect window re-size events, but this detects both height and width changes. Is there any way to detect just a width change and not a height change? thecodeparadox var width = $(window).width(); $(window).on('resize', function() { if ($(this).width() != width) { width = $(this).width(); console.log(width); } }); you can detect both events and just execute code when it's a width change: var lastWidth = $(window).width(); $(window).resize(function(){ if($(window).width()!=lastWidth){ //execute code here. lastWidth = $(window).width(); } }) And you might want

jQuery Off() not working in Chrome Extension

血红的双手。 提交于 2019-11-29 17:05:36
I've created a Chrome Extension based on https://thoughtbot.com/blog/how-to-make-a-chrome-extension (look at the end for the completed files) I've made two changes: I used JQuery 3.1.1 minimized instead of the older one given in the page above, and I changed content.js: chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) { if( request.message === "clicked_browser_action" ) { $(document).off("touchmove mousewheel mousemove scroll"); } } ); The $(document).off() command is not working when I click the extension's button with an appropriate test page opened. It doesn't

How to attach a event to a jQuery mobile page using on() and off()?

淺唱寂寞╮ 提交于 2019-11-29 12:38:56
I'm trying to upgrade to lasted Jquery 1.7.1 (using JQM 1.1pre). I used to be able to bind to a JQM page like this: $('#mypage').live('pageshow', function() { /* do stuff */ }) Per Jquery 1.7.1 this would now have to be: $('#mypage').on('pageshow', function() { /* do stuff */ }) Or if the page is dynamically inserted $('body').on('pageshow', '#mypage', function() { /* do stuff */ }) Questions: - Is this syntax correct for jquery 1.7+? - I cannot get the events to fire at all in JQM using this. I have tried $('div:jqmData(role="page")#mypage but this also does not seem to work. What would be

How do I attach a jQuery event handler to a YouTube movie?

一世执手 提交于 2019-11-29 10:24:46
问题 [EDIT: Sorry to those who already answered -- in my sleep-deprived state, I forgot that this particular situation is a YouTube movie, not the JW FLV player. I can see that there is more extensive documentation on interacting with YouTube movies, so I will pursue that, but any more information is also welcome] I am using embedded YouTube videos in a collection of divs that are being rotated by using the jQuery cycle plugin (http://malsup.com/jquery/cycle/). I would like the cycle to stop when

jQuery Mouse Direction Plugin [closed]

时光怂恿深爱的人放手 提交于 2019-11-29 07:23:43
Sorry, it's more of an answer than a question. I've seen many people asking how to identify directional mouse movements using js/jQuery and this is a plugin I wrote for them this afternoon. jQuery provides support for standard JS mouse events as well as some custom ones. In jQuery it's easy to capture whether mouse point has entered in the boundary of an object or left from (mouseenter, mouseleave) or something else happened (like click, dblclick etc). But you are in trouble if you need to capture the direction of your mouse. And it would be fantastic if there was a plugin which can fire

Twitter Bootstrap onclick event on buttons-radio

妖精的绣舞 提交于 2019-11-28 17:23:00
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). 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="btn-group"> <button type="button" class="btn active">Day</button> <button type="button" class="btn">Week<

Multiple JS event handlers on single element

本秂侑毒 提交于 2019-11-28 16:52:36
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 before it does meaning my new function isn't hit. The example scenario is I want to add a class to these