click

Why isn't my checkbox change event triggered?

蓝咒 提交于 2019-11-27 13:59:32
I have two functions. The first function translates a div click into a checked/unchecked toggle. The second function translates a checkbox change into a hide/show event. The problem is that when I use the first function to check/uncheck the box, the second function is not called. I am new to javascript, thanks. <script type="text/javascript"> $(document).ready(function() { $(":checkbox").parent().click(function(evt) { if (evt.target.type !== 'checkbox') { var $checkbox = $(":checkbox", this); $checkbox.attr('checked', !$checkbox.attr('checked')); evt.stopPropagation(); return false; } }); });

How to get a list of all elements that resides at the clicked point?

大兔子大兔子 提交于 2019-11-27 13:41:00
On user click I would like to get a list of all elements that resides at the clicked point . For example, if user clicks on Hello here: <div><span>Hello<span></div> I would like to get the following list: <span> element <div> element <body> element <html> element What would be the easiest method to get these elements ? EDIT: Based on clarification, I think this is what you mean: EDIT: As pointed out by @Misha , outerWidth() and outerHeight() should be used in lieu of width() and height() in order to get an accurate range . Also, if there's nothing to prevent event bubbling on the page, then

Matlab: How to get the current mouse position on a click by using callbacks

老子叫甜甜 提交于 2019-11-27 13:18:38
I googled near and far, but couldn't get an example of how you associate a callback to the click event in matlab. Can someone show me an example? Define the WindowButtonDownFcn of your figure callback using the set command and an @callbackfunction tag. Like so: function mytestfunction() f=figure; set(f,'WindowButtonDownFcn',@mytestcallback) function mytestcallback(hObject,~) pos=get(hObject,'CurrentPoint'); disp(['You clicked X:',num2str(pos(1)),', Y:',num2str(pos(2))]); You can also pass extra variables to callback functions using cell notation: set(f,'WindowsButtonDownFcn',{@mytestcallback

Combining elements for filtering with Isotope

▼魔方 西西 提交于 2019-11-27 12:52:19
问题 I'm currently using Isotope to filter a list of publications, but would like to be able to combine the standard, documented link-filter method with a select element, as my second list of filters is quite long. The bit I'm struggling with is dealing with two distinct types of element and combining selected values into one option array . I can make the filters work independently of each other (code below) but they need to work together. How can I combine the two different actions (click or

Difference between .click() and actually clicking a button? (javascript/jQuery)

♀尐吖头ヾ 提交于 2019-11-27 12:44:39
I'm trying to figure out this weird issue I've been having, and the root cause is the difference between a live click and triggering .click() . I won't get into the details of the problem, but basically when you click on the input button it works fine (has an onclick event). But if I call .click() from somewhere else (instead of physically clicking the button) it doesn't work properly. My question is - is there a way to truly replicate an actual click on a button? EDIT The problem: I'm opening a new window (aspx page) that loads an inline PDF. If I actually click on the link, the window opens

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

how to make div click-able?

狂风中的少年 提交于 2019-11-27 12:03:44
问题 <div><span>shanghai</span><span>male</span></div> For div like above,when mouse on,it should become cursor:pointer,and when clicked,fire a javascript function,how to do that job? EDIT : and how to change the background color of div when mouse is on? EDIT AGAIN :how to make the first span's width=120px?Seems not working in firefox 回答1: Give it an ID like "something", then: var something = document.getElementById('something'); something.style.cursor = 'pointer'; something.onclick = function() {

Programmatical click on <a>-tag not working in Firefox

时光总嘲笑我的痴心妄想 提交于 2019-11-27 12:01:39
I have a problem with the click() -function from jquery. I create a <a> -element with document.createElement('a') and want call the click() -function about this element. About this element, I want to create an Excel-file and save this at the desktop. My code: $('body').on('click', '#test', function(event) { var link = document.createElement('a'); link.download = 'test.xls'; link.href = 'data:application/vnd.ms-excel;utf-8,test'; link.click(); }); This function work under chrome, but not under Firefox. Working example Does anyone have any idea why that does not work? lurker In Firefox, you can

How to capture a mouse click on an Item in a ListBox in WPF?

為{幸葍}努か 提交于 2019-11-27 11:14:16
I want to get notified when an item in a ListBox gets clicked by the mouse, whether it is already selected or not. I searched and found this: ( http://kevin-berridge.blogspot.com/2008/06/wpf-listboxitem-double-click.html see the comments) private void AddDoubleClickEventStyle(ListBox listBox, MouseButtonEventHandler mouseButtonEventHandler) { if (listBox.ItemContainerStyle == null) listBox.ItemContainerStyle = new Style(typeof(ListBoxItem)); listBox.ItemContainerStyle.Setters.Add(new EventSetter() { Event = MouseDoubleClickEvent, Handler = mouseButtonEventHandler }); } //Usage:

jQuery bind click *ANYTHING* but *ELEMENT*

我的未来我决定 提交于 2019-11-27 10:39:00
Say there are some elements floating around, and I'm trying to do some when I click ANYTHING(divs, body, whatever...) but the one specified (e.g. div#special). I'm wondering if there's a better way to achieve this besides the following method I can think of... $(document).bind('click', function(e) { get mouse position x, y get the element (div#special in this case) position x, y get the element width and height determine if the mouse is inside the element if(inside) do nothing else do something }); To handle the "do this except when this element is clicked" situation, the general approach is