我无法使用jQuery触发body标签点击,我正在使用这个...
$('body').click();
Run Code Online (Sandbox Code Playgroud)
即便这样也失败了
$('body').trigger('click');
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?!
关注这篇文章,我有另一个发行者 - 当我点击文本链接时,如何在输入中触发浏览文件?
基本上我想隐藏表单,但是当你点击上传文本链接时会触发它.
<a href="#" class="upload">upload</a>
<form action="upload.php" method="post" enctype="multipart/form-data" id="myForm" style="display:none;">
<input type="file" multiple="multiple" name="file[]" />
<input type="submit" name="upload" value="Submit"/>
</form>
<div id="output"></div>
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的Javascript代码:
$(document).ready(function(){
$('.upload').click(function(){
$(this).trigger($('input[type=file]'));
return false;
});
$('input[type=file]').change(function() {
$('#myForm').ajaxSubmit({
target: '#output'
});
});
});
Run Code Online (Sandbox Code Playgroud) 我的Jquery代码遇到了一些问题.
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function() {
$(".upvote").on("click", function()
{
alert('test');
}
});
</script>
</head>
<body style="background-color:black; color:white;">
<form action="#" method="post">
<input type="submit" class="upvote" value=" + " />
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我点击按钮时,没有任何反应.我检查并确保我有jQuery 1.7.有人可以帮忙吗?
我想将按钮myButton添加到TextView.如何将它放在一行中,使其看起来像一组线.以下是要添加的文本示例
请在此处按此按钮刷新值集.
我希望将"here"作为可点击按钮.我该怎么做.它上面的任何片段都会有所帮助.
我有一个文本字段,我需要设置当用户从选择字段中选择一个选项或在文本字段中输入文本并点击链接时的值.然后这两个事件都会关闭包含select和text字段/链接的div.
选择选项有效
$(document).on("change", ".select_choice", function(event) {
var string = $(this).find("option:selected").text();
$(this).closest(".select_toggle_area").find(".toggle_choices").toggle();
$(this).closest(".select_toggle_area").find(".target_input").val(string);
});
Run Code Online (Sandbox Code Playgroud)
文本字段/链接在第二次单击时起作用.无论何时在字段中输入内容,链接在第一次单击时都不起作用.它隐藏div,但不更新目标字段的值.
$(document).on("click", ".text_choice_button", function(event) {
event.preventDefault();
var string = $(this).closest(".select_toggle_area").find(".text_choice").val();
$(this).closest(".select_toggle_area").find(".target_input").val(string);
$(this).closest(".select_toggle_area").find(".toggle_choices").toggle();
});
Run Code Online (Sandbox Code Playgroud) 嗨我正在使用Selenium Standalone Server和Selenese命令执行程序在Mac OS X上测试Safari.我在单击特定页面上的某些按钮时遇到问题.同样的点击在其他浏览器中也能完美运行,如firefox(Windows),chrome(Windows + Mac),IOS模拟器,IE.我也能通过id获取按钮.通过使用getText()获取按钮文本来确认.在click命令之后,没有任何事情发生.我尝试过使用button.click(),button.submit().还使用id,xpath,类来查找按钮.正如我所提到的:我能够获得id,只是点击不起作用.有什么建议?一些代码是:
public static WebDriver getSafariDriver()
{
try
{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setBrowserName("safari");
capabilities.setJavascriptEnabled(true);
CommandExecutor executor = new SeleneseCommandExecutor(new URL("http://localhost:4444/"), new URL("http://www.google.com/"), capabilities);
WebDriver driver = new RemoteWebDriver(executor, capabilities);
return driver;
} catch (MalformedURLException e)
{
e.printStackTrace();
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
是否有通过命令提示符的解决方法?或者其他任何我可以尝试或错过的东西?请帮忙.
我有以下代码:
<script type="text/javascript">
$(document).ready(function(){
shortcut.add("Ctrl+Alt+N", function() {
$("#btnSave").click();
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
其中btnSave是ID为btnSave的锚元素,快捷方式来自http://www.openjs.com/scripts/events/keyboard_shortcuts/.如果我改线$("#btnSave").click();到document.getElementById("btnSave").click()-一切工作正常.问题是为什么jquery实现在我的情况下不起作用?
PS:为我的案子制作了jsfiddle:http://jsfiddle.net/0x49D1/WCmeU/
这是有类似问题的人:http ://forums.asp.net/t/1591818.aspx
我正在创建一个脚本,每次按下按钮时都会创建div元素.最初我有一个名为内联onclick属性的函数,但jslint不喜欢这样,所以我把它移出来,而是尝试使用addEventListener("click",function());
我以前从未使用addEventListener()过,所以我甚至不确定我是否正确使用它.
问题是它div在页面加载时创建一个,并且在按下按钮时不会执行任何操作.
先感谢您.
这就是我所拥有的:
<body>
<form>
<textarea id="a"></textarea>
<br>
<input value="button" type="button">
</form>
<div id="content">
</div>
<script>
/*jslint browser:true */
function createEntry(text) {
"use strict";
var div = document.createElement("div");
div.setAttribute("class", "test");
document.getElementById("content").appendChild(div);
}
var input = document.getElementsByTagName("input")[0];
input.addEventListener("click", createEntry(document.getElementById('a').value));
</script>
Run Code Online (Sandbox Code Playgroud)
我有几个问题..
我正在使用Kendo网格,并且想知道在更改行选择时是否可以在文档级别触发事件.
基本上,当行选择被更改时,我想触发一个事件,这是在全局级别完成的,而不依赖于gridID.
例:
$('tr.k-state-selected').parents('tbody').live('change',function(e){alert("onchange");}); }
但上面的例子不起作用.我没有在grid/body/gridRow上定义任何其他类.
如何使用kendo窗口上的span类触发单击事件(弹出窗口)
我试过下面的代码,但这不起作用
$('span.k-icon.k-i-close').parents('a').click(function (e) {
alert("clicked!");
});
Run Code Online (Sandbox Code Playgroud)我是否需要包含任何adidtional类来识别kendo窗口?
任何帮助都感激不尽.提前致谢.
我在php中有一个foreach循环,如下所示.
<?php
$i = 0;
foreach ($query as $value) { ?>
<button id="show[<?php echo $i;?>]" class="btn btn-success" type="button">View</button>
<div id="blah[<?php echo $i;?>]">Joel</div>
<?php
$i++
} ?>
Run Code Online (Sandbox Code Playgroud)
现在这个循环工作正常,我得到每个按钮和具有唯一ID的div的id.但我想添加一个jquery点击功能,如下所示.
$("#show").click(function(){
$("blah").hide();
});
Run Code Online (Sandbox Code Playgroud)
但是因为它在一个循环中并且与它们有不同的id如何为每个按钮添加这个jquery函数?