我尝试将脚本更改为以下内容,但仍然没有触发事件..我错过了什么吗?
$('#page1').live('pageshow',function(event) {
$("#radioyes").click(function(){
$("p").hide();
});
});
Run Code Online (Sandbox Code Playgroud)
我也试过,pagebeforecreate但结果是一样.. :(
我正在尝试一个简单的jquery移动页面并测试chrome便携式.但是,在以下代码中,输入单击事件在按钮单击工作的位置不起作用.我也尝试"input#radioyes"作为"div>fieldset>input#radioyes",仍然不起作用.
<!DOCTYPE html>
<html>
<head>
<title>Background check </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="images/touch-icon-iphone.png" />
<link rel="apple-touch-icon" sizes="72x72" href="images/touch-icon-ipad.png" />
<link rel="apple-touch-icon" sizes="114x114" href="images/touch-icon-iphone4.png" />
<script type="text/javascript" src="jQuery/jquery.js"></script>
<script type="text/javascript" src="jQuery/jquery.mobile.min.js"></script>
<link rel="stylesheet" href="jQuery/jquery.mobile.min.css" />
<!-- JQuery Date Picker components -->
<link rel="stylesheet" href="jQuery/jquery.ui.datepicker.mobile.css" />
<script src="jQuery/jQuery.ui.datepicker.js"></script>
<script src="jQuery/jquery.ui.datepicker.mobile.js"></script>
<link rel="stylesheet" href="css/folo.css" /> …Run Code Online (Sandbox Code Playgroud) 如果我有一个jQuery .click()事件触发"body"和"div",我怎么才能让它只执行div而不是单击div时的body?基本上,我正在创建自己的上下文菜单,我想要点击元素外的任何地方(在这种情况下,"div.button")来关闭菜单.
基本的例子:
$("body").click(function(event){
if($("div.menu").is(":visible")){
$("div.menu").hide();
}
});
$("div.button").click(function(event){
$("div.menu").show();
});
Run Code Online (Sandbox Code Playgroud)
你可以猜到,$("body").click()会阻止/隐藏菜单甚至显示.
一点指导将非常感激.谢谢阅读!
我正试图在li选项卡上使用addClass('current').问题是click函数调用load(),它会重置li选项卡上的当前类.如何在访问者点击的li上的load()之后添加addClass()?
我现在的表现如何:
$('div#container ul.tab-nav li').click(function(event) {
$('div#container').load('index.htm').fadeIn("slow");
$('div ul.tab-nav li').removeClass('current');
$(this).addClass('current');
event.preventDefault();
return false;
});
<ul class="tab-nav">
<li class="current">1</li>
<li>2</li>
<li>3</li>
</ul>
Run Code Online (Sandbox Code Playgroud) 我试图用C#中的鼠标获取点击的坐标与我的表格中的面板相关,但我不知道该怎么做.我是一个乞丐,我对事件没有任何经验.谢谢!
可能重复:
jquery on vs click方法
我理解这$(parent).on('click', 'element', function(){ ...用于将单击处理程序附加到动态创建的元素 - 而$('element').click(...只有在元素存在于初始页面加载时才有效.到目前为止,我总是使用.on()一切,因为它涵盖了两者 - 我的问题是 - 是否有时间.click是首选,或任何其他我不知道不使用的优点.on()
我想在Jlabel文本中包含可单击的单词,我想为每个单词注册一个MouseListener或获取单击的单词(否则).下图显示了我想要的内容.这可能吗 ?!

我做了一个侧面导航菜单,点击一个按钮从左到右滑动.
$(document).ready(function(){
$("#nav-toggle").click(function(){
$("#page").toggleClass("margin");
});
});
Run Code Online (Sandbox Code Playgroud)
当点击'#nav-toggle'按钮时,'#page'边距从0px增加到600px.
.margin {
margin-left:600px;width:380px;overflow-x:hidden
}
<div id="side-menu">
<nav>
<a class="nav-links" href="#home">home</a>
<a class="nav-links" href="#about">about</a>
<a class="nav-links" href="#contact">contact</a>
</nav><!-- end of nav -->
Run Code Online (Sandbox Code Playgroud)
如何通过点击它外面关闭菜单.
我希望我的click函数能够运行所有元素,并且我希望获得单击的元素标记名称.
对于这样的页面,例如,
<html>
<body>
<form>
<div>
<input type="text">
<textarea></textarea>
</div>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
如果我运行这个js代码
$("*").live('click',function(evt) {
alert(evt.target.tagName);
});
Run Code Online (Sandbox Code Playgroud)
然后点击textarea,它会提醒"TEXTAREA"5次,因为它有4个父母.
在哪里修理?
我在pygame中制作了用于单击事件的按钮,但是存在问题。当我单击鼠标按钮并在按钮边界之间移动鼠标时,单击事件会重复发生。我只想单击一下,直到释放鼠标按钮。我怎样才能做到这一点?
import pygame,time
pygame.init()
x,y = (200,300)
pencere = pygame.display.set_mode((x,y))
pygame.display.set_caption("Click")
white = (255,255,255)
black = (0,0,0)
black2 = (30,30,30)
class Counter:
count = 0
def click(self):
self.count += 1
number = Counter()
def text_objects(text, font, color):
textSurface = font.render(text, True, color)
return textSurface, textSurface.get_rect()
def button(msg,x,y,w,h,c,ic,action=None):
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
pygame.draw.rect(pencere, c,(x,y,w,h))
smallText = pygame.font.Font("freesansbold.ttf",20)
textSurf, textRect = text_objects(msg, smallText, white)
textRect.center = ( (x+(w/2)), (y+(h/2)) )
pencere.blit(textSurf, textRect)
if x+w > mouse[0] > x and y+h …Run Code Online (Sandbox Code Playgroud)