为了向选择列表添加一个很长的选项元素列表,我点击它们添加它们.我想防止列表多次添加.我怎样才能做到这一点?
$("#skiresort").click(function(){
$("#skiresort").load("/v3/inc/review.php");
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个页面,其中示例div是可点击的,因为它将在下面.
但是我试图这样做,如果用户点击徽标,它将使用加载重新加载原始内容.
发生此负载后,是否可以"点击"加载<div id="example">?我正在尝试此操作,并且在单击<div id="example">file.php中的已加载时无法发出警报
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#example").click(function(){
alert("You clicked me!");
});
$("#logo").click(function(){
$("#main").load("file.php");
});
});
</script>
</head>
<body>
<img id="logo" src="404.gif" />
<div id="main">
<div id="example">This is content.</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
file.php包含
<div id="example">This is loaded content that can't be clicked?</div>
Run Code Online (Sandbox Code Playgroud) 我正在尝试触发点击事件,当用户点击按钮时会打开我的href sip/tel链接,但是在按下按钮后它不会触发点击事件.
jquery代码:
$('#next_button').click(function() {
var num = $(this).val();
$('#call-num'+num).trigger('click');
alert(num);
});
Run Code Online (Sandbox Code Playgroud)
href代码:
<a href="tel:001(999) 888-3333" id="call-num1">(999) 888-3333</a>
<button id="next_button" value="1">Next</button>
Run Code Online (Sandbox Code Playgroud) 是否可以在设定的时间间隔模拟点击链接或任何标签?
原因:我有一个没有自动旋转功能的插件,但只能在单击 Next 和 Prev 链接时起作用。所以我想写一个自动点击的函数。
所以我在我的页面上运行了jQuery滚动.但我想改变一件事.我不想在网址中显示锚文本.即.#products或#contactinfo
HTML代码:
<div>
<a href="#products">Products</a>
<a href="#contactinfo">Contact info</a>
</div>
<div id="products"></div>
<div id="contactinfo"></div>
Run Code Online (Sandbox Code Playgroud)
jQuery代码:
$(document).ready(function(){
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 900, 'swing', function () {
window.location.hash = target;
});
});
});
Run Code Online (Sandbox Code Playgroud) 我试图在用户点击td内部的任何元素时发出一个点击事件tbody.这是我到目前为止所得到的,但它没有提出事件,任何想法为什么?
<head runat="server">
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$("#skuOptionsBody td").click(function () {
alert('clicked!');
});
</script>
</head>
<body>
<form id="form1" runat="server">
<table id="options" border="1">
<thead>
<tr>
<td>
SWEET OPTION
</td>
<td>
DRINK OPTION
</td>
</tr>
</thead>
<tbody id="skuOptionsBody">
<tr>
<td style="text-align: center">
SO1
</td>
<td style="text-align: center">
DO1
</td>
</tr>
</tbody>
</table>
</form>
</body>
Run Code Online (Sandbox Code Playgroud)
更新:
对不起,我忘了提到我使用jQuery动态地向表添加行,因为我正在添加新行,我需要它们绑定到这个click事件.如何做到这一点?
$('document').ready(function() {
$('.button').click(function() {
$('img').animate({left: "+80px"}, 2000);
});
});
Run Code Online (Sandbox Code Playgroud)
所以,我对jQuery和其他东西有点新手.我想要做的就是每次单击按钮时使图像向右移动.当我运行它时,它第一次工作,但当我再次单击该按钮时,它仍然保持静止.
我想知道如何多次触发.click事件.
PS:如果值得知道,我在这里提到的按钮实际上是一个<div>.我无法使用它<button>.
我是Javascript和jQuery的新手。用户提交表单后,我想显示“ loading-gif”,但无法弄清楚我的代码为什么不起作用。就是这种情况:
那是我的javascript(在html页面底部的jquery之后初始化):
$('.formtrigger').click(function() {
$('#loading').show();
$('#form').submit();
});
Run Code Online (Sandbox Code Playgroud)
当我单击按钮时,表单已提交,但未显示loading-div。我尝试了行“ $('#loading')。show();” 而不将其绑定到点击事件上,并且可以正常工作。我也尝试了这段代码:
$('.formtrigger').click(function() {
alert('blablabla');
$('#form').submit();
});
Run Code Online (Sandbox Code Playgroud)
并且两个语句都起作用!首先显示警报,然后提交表单。为什么其他代码不起作用?
提前致谢。
编辑:我也尝试了以下变种而没有成功
$('.formtrigger').click(function() {
$('#form').submit();
});
$('#form').submit(function() {
$('#loading').show();
});
Run Code Online (Sandbox Code Playgroud)
和
$('.formtrigger').click(function() {
$('#loading').show();
window.setTimeout($('#form').submit(), 5000);
});
Run Code Online (Sandbox Code Playgroud)
和
//HTML
<button type="submit">...</button>
//JS
$('#form').submit(function() {
$('#loading').show();
});
Run Code Online (Sandbox Code Playgroud) 我想知道是否有任何方法可以获得压力水平(用户点击鼠标键/按钮时的压力)点击.任何资源或链接?
抱歉我的英文不好,希望我的问题很清楚,希望不仅仅是乌托邦!
我使用jQuery在按钮上设置了一个事件监听器,由于某种原因,在没有单击按钮的情况下调用click监听器中的函数.我知道通常函数在侦听器中是匿名的,但它不能用作匿名函数.我调用的函数也必须接受参数,这就是为什么我认为我不能只调用函数的引用.关于如何解决函数问题的任何想法,如果没有点击甚至注册,仍然将必要的参数传递给函数?
$('#keep-both').click(keepBothFiles(file, progress, audioSrc));
Run Code Online (Sandbox Code Playgroud)
调用此功能
function keepBothFiles(file, progress, audioSrc) {
...
...
}
Run Code Online (Sandbox Code Playgroud) javascript jquery event-listener jquery-click-event jquery-events