假设有一些元素漂浮在周围,当我点击ANYTHING(divs,body,等等......)但是指定的那个(例如div#special)时,我正试图做一些.
我想知道是否有更好的方法来实现这一点,除了我能想到的以下方法......
$(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
});
Run Code Online (Sandbox Code Playgroud) 我在for循环中有一组动态生成的锚标记,如下所示:
<div id = "solTitle"> <a href = "#" id = "' + tagId + '" onClick = "openSolution();"> ' + solTitle + '</a></div> <br>';
Run Code Online (Sandbox Code Playgroud)
执行此代码后,其中一个案例的html输出将如下所示:
<div id = "solTitle"> <a href = "#" id = "solution0" onClick = "openSolution();">Solution0 </a></div> <br>
<div id = "solTitle"> <a href = "#" id = "solution1" onClick = "openSolution();">Solution1 </a></div> <br>
Run Code Online (Sandbox Code Playgroud)
现在我希望在点击上面的链接时显示不同的文本.openSolution()看起来像这样:
function openSolution() {
alert('here');
$('#solTitle a').click(function(evt) {
evt.preventDefault();
alert('here in');
var divId = 'summary' + $(this).attr('id');
document.getElementById(divId).className = '';
});
} …
Run Code Online (Sandbox Code Playgroud) 第二次更新:看起来我的一个函数(resetFigures)阻止了事件处理程序,所以将它移动到bind函数的末尾就将其排序了.
更新:我在经过一些基本测试后意识到点击事件正在注册,只是在点击时盒子无法翻转.
我的网站基本美学功能在Chrome和Firefox中运行,但它拒绝在iOS上正常运行(在带有iOS 6.1的iPhone 4和带有iOS 4.3.5的iPad上进行测试).
您可以在此处查看该站点,当然还有脚本(main.js):http://bos.rggwebdesigns.com/
我已经读过iOS并没有真正正确地处理jQuery点击事件,但我很难找到解决方法.Stack Overflow上的一些线程提到了live()方法,但实现它如下(以及添加onclick=""
到可点击元素)似乎不起作用:
$('.card').live('click touchstart', function() {
var figure = $(this).children('.back');
var button = figure.find('.button');
var column = $(this).parents().eq(1);
$('.column').removeAttr('style');
column.css('z-index', 2000);
resetFigures();
if(flipCard(this)){
swoosh.pause();
swoosh.currentTime = 0;
swoosh.play();
}
});
Run Code Online (Sandbox Code Playgroud)
我还遇到了这个有趣的解决方案项目:http://aanandprasad.com/articles/jquery-tappable/.但是,我也没有运气:
$('.card').tappable(function() {
var figure = $(this).children('.back');
var button = figure.find('.button');
var column = $(this).parents().eq(1);
$('.column').removeAttr('style');
column.css('z-index', 2000);
resetFigures();
if(flipCard(this)){
swoosh.pause();
swoosh.currentTime = 0;
swoosh.play();
}
});
Run Code Online (Sandbox Code Playgroud)
此外,如果我被误导,请纠正我,但根据此网站,iOS支持3D转换,并提供相应的前缀:http://caniuse.com/transforms3d
我试图模拟元素上的单击.相同的HTML如下
<a id="gift-close" href="javascript:void(0)" class="cart-mask-close p-abs" onclick="_gaq.push(['_trackEvent','voucher_new','cart',$(this).attr('rel')+'-mask_x_button-inaction']);" rel="coupon"> </a>
Run Code Online (Sandbox Code Playgroud)
我怎样才能模拟点击它.我试过了
document.getElementById("gift-close").click();
但它没有做任何事情
我是python selenium的新手,我试图点击一个具有以下html结构的按钮:
<div class="b_div">
<div class="button c_button s_button" onclick="submitForm('mTF')">
<input class="very_small" type="button"></input>
<div class="s_image"></div>
<span>
Search
</span>
</div>
<div class="button c_button s_button" onclick="submitForm('rMTF')" style="margin-bottom: 30px;">
<input class="v_small" type="button"></input>
<span>
Reset
</span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我希望能够点击上面的Search
和Reset
按钮(显然是单独的).
我尝试了几件事,例如:
driver.find_element_by_css_selector('.button .c_button .s_button').click()
Run Code Online (Sandbox Code Playgroud)
要么,
driver.find_element_by_name('s_image').click()
Run Code Online (Sandbox Code Playgroud)
要么,
driver.find_element_by_class_name('s_image').click()
Run Code Online (Sandbox Code Playgroud)
但是,我似乎总是最终得到NoSuchElementException
,例如:
selenium.common.exceptions.NoSuchElementException: Message: u'Unable to locate element: {"method":"name","selector":"s_image"}' ;
Run Code Online (Sandbox Code Playgroud)
我想知道我是否能以某种方式使用HTML的onclick属性来进行selenium点击?
任何可以指向正确方向的想法都会很棒.谢谢.
单击GridView中的项目时,如何关闭橙色突出显示?
我无法在文档中或通过测试找到解决方案.
我知道之前已经问过这个问题,但在网上搜索之后我似乎无法找到一个直截了当的答案.
HTML
<a id=myAnchor href=index.php>
Run Code Online (Sandbox Code Playgroud)
jQuery(这两个都不起作用)
$('#myAnchor').click();
Run Code Online (Sandbox Code Playgroud)
要么
$('#myAnchor').trigger('click');
Run Code Online (Sandbox Code Playgroud)
实现这一目标的最简单,最有效的方法是什么?
我想知道是否有可能检测到JavaFX 2中的双击?如何 ?
我想在点击和双击之间进行不同的事件.
谢谢
我正在开发一个角色应用程序供管理人员跟踪他们的团队,我遇到了@Output错误:
An error occurred: @Output deleteMeeting not initialized in 'MeetingItemComponent'.
Run Code Online (Sandbox Code Playgroud)
我有一个Meetings组件,生成一个MeetingItem组件列表.我想在用户点击不同按钮(编辑,删除,显示详细信息)时执行操作.
这是我的父会议模板:
<div class="meeting__list" [@newMeeting]="meetings.length">
<app-meeting-item
*ngFor="let meeting of meetings"
[meeting]="meeting"
(deleteMeeting)="deleteMeeting($event)"
(openMeetingDialog)="openMeetingDialog($event)"
(messageClick)="openMessage($event)"
></app-meeting-item>
</div>
Run Code Online (Sandbox Code Playgroud)
我的MeetingItem模板(仅此帖子涉及的部分):
<span class="meeting__actions">
<mat-icon *ngIf="meeting.message" (click)="onMessageClick(meeting)" matTooltip="Read the message"
matTooltipPosition="above" class="icon--notes">notes</mat-icon>
<mat-icon (click)="onOpenMeetingDialog(meeting)" matTooltip="Edit this meeting" matTooltipPosition="above" class="icon--edit">edit</mat-icon>
<mat-icon (click)="onDeleteMeeting(meeting.id)" matTooltip="Delete this meeting" matTooltipPosition="above" class="icon--delete">delete_outline</mat-icon>
</span>
Run Code Online (Sandbox Code Playgroud)
我的MeetingItem组件:
import { Component, Input, Output } from '@angular/core';
import { EventEmitter } from 'events';
@Component({
selector: 'app-meeting-item',
templateUrl: './meeting-item.component.html',
styleUrls: ['./meeting-item.component.scss']
})
export class MeetingItemComponent {
@Input() …
Run Code Online (Sandbox Code Playgroud) 我有一个像这样的wpf按钮:
<Button Click="button1_Click" Height="23" Margin="0,0,5,0" Name="button1" Width="75">Initiate</Button>
Run Code Online (Sandbox Code Playgroud)
我想将pass {Binding Code}
作为参数传递给button1_click处理程序.
我该怎么做?
免责声明:WPF真的很新