Tag: function

在超时期间更改mouseenter上的div颜色 – jquery函数

现在我有这个代码: $(‘.a’).mouseenter(function(){ var $this = $(this); clearTimeout($this.data(‘timerMouseleave’)); $this.css(‘border’, ‘solid 1px #444444’) }).mouseleave(function(){ var $this = $(this); var timer = setTimeout($.proxy(function(){ $this.css(‘border’, ‘solid 1px #dddddd’) }, this), 1000) $this.data(‘timerMouseleave’, timer) }).click(function(){ var $this = $(this); $this.css(‘border’, ‘solid 1px black’) $this.off(‘mouseenter mouseleave’); }) http://jsfiddle.net/7dXAs/6/ 我想在超时仍然打开的情况下再次输入div时添加红色边框。 (如果可能的话,请包括在这种情况下播放声音,例如aaa.wav)。 我需要完全保持这种行为的其余部分,这意味着红色边框通常应该在超时后更改回默认值。 澄清 : mouseleave后触发超时/延迟并持续1秒。 当前情况:如果在1秒到期之前再次输入div,则会删除超时,然后在另一次mouseleave之后再次触发 想要的情况:如果你在1秒到期之前再次输入div, 边框变为红色 ,超时被删除,然后在另一个mouseleave之后再次触发

“记住”div的点击风格(设置一个cookie) – jquery和jquery cookie插件

我有一组带有mouseenter,mouseleave和click事件的div。 var originalAttributes = $(‘.aaa’).attr(‘style’); $(‘.aaa’).mouseenter(function () { $(this).css(‘background’, ‘#aaaaaa’); $(this).css(‘border’, ‘solid 1px red’); }); $(‘.aaa’).mouseleave(function () { $(this).css(‘background’,’blue’); }); $(‘.aaa’).click(function () { var $this = $(this); update_x1(this); $this.off(‘mouseenter mouseleave’); }); $(‘#save’).click(function () { $.cookie({ expires: 30 }); }); $(‘#clear’).click(function () { $(‘.aaa’).attr(‘style’,originalAttributes); }); http://jsfiddle.net/z8KuE/24/ 如何在此function和jquery cookie插件的使用中实现“保存”和“清除”function? 点击“保存”应“记住”div的当前样式,然后单击“清除”应将样式重置为原始并清除cookie(或重写)。 编辑:由Shimon Rachlenko解决 – http://jsfiddle.net/z8KuE/31/

jquery切换function并设置cookie

我有以下function,可以在点击时切换mouseenter和mouseleave: var flag = true; $(‘.aaa’).mouseenter(function () { if(flag) { $(this).css(‘background’, ‘#aaaaaa’); } $(this).css(‘border’, ‘solid 1px red’); }); $(‘.aaa’).mouseleave(function () { if(flag) { $(this).css(‘background’,’blue’); } $(this).css(‘border’, ‘solid transparent 1px’); }); $(‘#tog’).click(function () { flag = !flag; }); http://jsfiddle.net/z8KuE/15/ 如何选择偏好“记住”并加载到下一页加载? 编辑:如果由于某种原因来自bellow的解决方案在网站上不起作用,请将其放在此处: (function($){ $(document).ready(function(){ //Scripts go in here! }); })(jQuery);

Jquery – 从使用函数创建的按钮调用函数

这适用于Jquery: $(“.go”).click(function() { $(“#test”).html(“TEST TEST TEST”); }); 但是,如果我尝试从使用以下创建的按钮访问go函数,则会失败。 $(“.new”).click(function() { $.ajax({ url: $(this).attr(“data-value”), success: function(data, textStatus, xhr) { $(‘#DIV’).html(”); } } }); }); 当另一个function点击function完成时,使用此代码。 有什么理由吗? 谢谢

将从jqueryui autocomplete返回的值传递给另一个函数

这是我的用例:用户选择从自动完成查找返回的选项。 从查找返回的数据被分配给表单上的许多其他输入框。 进一步在表单中,用户进入选择框,在那里他们选择“链接类型”。 链接类型的选择触发第二个函数,该函数将一些默认值(例如链接描述的样板文本)分配给某些相关的输入框。 问题:如何将从自动完成function中选择的值传递给第二个function? 这是自动完成代码: $(‘#chooseChannel’).val(“”); $(‘#chooseHLProgName’).val(“”); $(“#chooseHLProgName”).autocomplete({ source: function( request, response ) { $.getJSON( ‘/test/myCFC.cfc?’, { method: ‘qryMyMethod’, returnformat: ‘json’, searchTerm: request.term, dsn: ‘myDSN’, virtChannel: $(‘#chooseChannel’).val() }, response ); }, minLength: 3, select: function(event,ui) { $(‘#seriesID’).val(ui.item.seriesid), $(‘#versionID’).val(ui.item.versionid), $(‘#channel’).val($ (‘#chooseChannel’).val() ), $(‘#chooseHLTitle’).val(ui.item.progFullTitle), $(‘#chooseHLDesc’).val(ui.item.progDesc), $(‘#chooseHLDateTimeInfo’).val(ui.item.progDateTime), $(‘#setScheduleURL’).val(‘/schedules/listingDetails.cfm?seriesID=’ + ui.item.seriesid + ‘&versionID=’ + ui.item.versionid + ‘&virtChannel=’ + […]

检查是否在一定时间内点击了“没有”按钮(jQuery)

基本上: 单击一个按钮,它将运行function1。 如果您未在1秒内再次单击该按钮,则运行function2。 如果在1秒内单击该按钮,则再次运行function1。 等等等等… 我无法弄清楚在Javascript中执行此操作的逻辑。 还有办法吗? 提前致谢!

Javascript ForEach函数在IE中不起作用

我怎么能写下以下所有浏览器都支持的代码? 因为似乎IE8中不支持forEach-Function … digits.forEach( function( value, index ) { // create a span with initial conditions var span = $( ”, { ‘class’: ‘digit0’, ‘data’: { ‘current’: 0, ‘goal’ : value } } ); // append span to the div#number span.appendTo( $( ‘div#number’ ) ); // call countUp after interval multiplied by the index of […]

不能将文本字符串传递给jquery函数?

我的jquery脚本出了什么问题? 这是脚本 function debug(message){ $(“body”).append(“”+ $(message) +””): } debug(“show this debug message in the div”); 这是我得到的html [object Object] 我期待的HTML就是这个 show this debug message in the div

Jquery – 模拟单击​​按钮不会触发function

好, 所以我一直在使用firebug以及我写的一些扩展,以便在我经常使用的网站上创建快捷方式。 我不明白为什么它不起作用或为什么它不可能: 示例代码: //This will add a new row to the current table. //The function is defined by the website (not my function) 使用firebug时: jQuery(“#addRow”).click(); //This will simulate the button click, and will automatically add the new row. 使用谷歌浏览器扩展程序时: jQuery(“#addRow”).click(); //It doesn’t add the new row. 一旦按钮发生单击,为什么扩展不能执行该function,为什么firebug在运行它时没有问题? 这是正常的吗? 这是安全function吗? 或者我做错了什么? 我知道出于安全原因我无法访问网站中的现有function,但为什么按钮模拟不能为我触发它?

PHP函数与jQuery AJAX?

我有一个关于PHP函数,jQuery和AJAX的问题。 如果我的php索引中有一个按钮,如下所示: 我有另一个PHP文件(dubs.php),其中包含: 我的jQuery,像这样: $(document).ready(function(e) { $(“#download”).click(function(){ $.ajax({ type: “GET”, url: “dubs.php”, }); }); }); 如何告诉我的AJAX请求选择第二个函数? 我不知道如何做到这一点,我已经用”success: first()”或者”success: function(){ first() }”尝试它,但这不起作用。