Tag: onclick

在表单提交上触发谷歌分析事件

我正在尝试将分析事件跟踪添加到onclick事件中,以便在表单上提交输入。 我尝试了多个不同的例子,并引用了几个不同的SOpost来达到这一点。 我可以让onclick提交表单或触发跟踪事件,但不能同时触发。 第一个例子:(将表单+日志提交到控制台但不触发事件) 第二个例子:(触发事件+日志到控制台但不提交表单) 我还发现,如果我将return false添加到第一个示例的onclick事件的末尾,它将触发分析事件跟踪但不提交表单。

使用jQuery .click()(或类似)在href属性中触发javascript

不幸的是,我正在使用一些第三方javascript,它会在我的页面中插入链接。 我不想直接使用这些链接,而是使用代理元素,当单击它们时,会触发第三方链接上的click事件。 第三方链接将javascript包装到href属性中,如下所示: Click me 我的代理元素如下所示: No, click me 还有一些jQuery的javascript将它们链接在一起: $(‘button.linkProxy’).click(function(){ $(‘#’ + $(this).attr(‘rel’)).click(); }); 现在,如果第三方链接只是一个标准链接( Click ),或者稍微不那么可怕的onclick , Click ( Click ),但当javascript在href属性中时,触发’click’什么都不做。 谁能告诉我为什么,以及是否有合理的解决方法? 更新为Millimetric说,根本原因似乎是浏览器阻止了对锚点的“伪造点击” – 我已经删除了我的“标准链接”示例,因为这是另一种无效的情况。 但是,正如您所期望的那样,onclick处理程序确实可以正常工作。

单击父图像时不显示图像

function: 当用户进入第一页时,主图像被随机化并显示。 因此,当用户点击主图像(第一图像)时,将显示二次图像(第二图像)。 次要图像是第1图像的扩展,因此,例如,当用户点击苹果的第1图像时,显示蠕虫的第二图像。 我做了什么: 我已将第1张图像和第2张图像都设置为一组数组。 其次,第一图像的arrays是随机的,因此,我已经将第二图像arrays设置为附加到第一随机图像。 我已附上以下代码供您阅读: //Brand Array var BrandNameArray = [“http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”]; //Corresponding Image Array var OfferArray = [“http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”, “http://loremflickr.com/g/320/240/paris,girl/all”]; $(function() { //Auto populate into brand container once randomised for each Brand […]

两个滚动条问题?

继续这篇文章 ,我做了一个测试,但是我仍然遇到了一些问题 – 当你点击显示图片时,页面有两个滚动条。 我在显示图像时不需要背景滚动条,我只需要图像容器上的滚动条。 如何在不使页面跳跃的情况下隐藏背景滚动条? css, #container-image { position: fixed; top: 0; left: 0; width: 100%; height: 100%; overflow-x: auto; overflow-y: scroll; z-index:100; } HTML, Please scroll down until you see the click button click jquery, $(document).ready(function(){ $(‘.get-photo’).click(function(){ var object = $(this); var object_path = object.attr(‘href’); var scroll_top = $(window).scrollTop(); //alert(object_path); $(‘#container-image’).show(); return false; […]

使用jquery手动预览幻灯片

请轻松 – 第一篇文章! 希望修改以下脚本: http : //jonraasch.com/blog/a-simple-jquery-slideshow 喜欢它的简单性,试图找到一种方法来添加一个高级function 最好是在img或div-on点击或链接。 有什么建议? 感谢帮助 编辑 ,下面是脚本,这里是工作版本的链接: 链接到实时测试页面 脚本: function slideSwitch() { var $active = $(‘#slideshow IMG.active’); if ( $active.length == 0 ) $active = $(‘#slideshow IMG:last’); // use this to pull the images in the order they appear in the markup var $next = $active.next().length ? $active.next() : […]

Jquery在点击时改变div的不透明度

我已经阅读了有关此事的各种问题,但我没有找到针对我的具体案例的解决方案。 我需要在单击时更改thumbUp和thumbDown div的不透明度。 为什么我的代码不起作用? 谢谢。 HTML Feu d’artifice Giacomo Balla 1916-1917 Ti piace quest’opera? CSS #likeButtons{ position:relative; right:-50%; width:500px; overflow:hidden; font-weight:300; margin-bottom:50px; } #likeButtons p{ float:left; } #likeButtons img{ width:10%; margin-bottom:30px; padding-left:10px; float:left; cursor:pointer; } #thumbUp,#thumbDown{ opacity:0.6; } JQuery的 $(document).ready(function(e) { $(‘#pulsanteOpera’).click(function(){ $(this).toggleClass(‘pulsante’).toggleClass(‘pulsanteRimuovi’); }); $(‘#thumbDown’).click(function(){ if($(this).css(‘opacity’)==0.6) $(this).css(‘opacity’,’1.0′); else $(this).css(‘opacity’,’0.6′); }); });

使用jQuery更改为单击图像上的选项

如果我点击某个图像,我想将选项更改为选择。 option的值是参数的唯一ID。 我想使用jQuery,但我是初学者,我不知道如何。 现在我有这个: $(document).ready(function () { $(‘img’).click(function(){ $(“option:selected”).removeAttr(“selected”); $(‘option[value=”‘ + $(this).attr(“alt”) + ‘”]’).attr(‘selected’, true); }); }); 但它不起作用。 所有来源都在这里http://jsfiddle.net/EKaKw/2/ 。 回答jsfiddle是最好的。 谢谢你。

单击时为表单数组添加值

我有下面的代码工作onclick。 1 2 3 4 5 当您选择1时,a,b,c的隐藏字段的值为1。 这很好但是我在这里有一个更大的项目,用户可以在整个表单中为’a’选择多个值。 没有onclick我可以很好地工作,例如 但是,当我这样做 1 2 3 4 5 我的隐藏价值没有插入任何内容。 为什么是这样? 有没有更好的方法来做我想用jQuery做的事情?

JQuery onclick只工作一次

我有一个按钮onclick事件,在这里工作正常: // create function to remove “popup-open” classes // function used in onclick attribute (function( $ ){ $.fn.popupClose = function() { $( “body” ).removeClass( “popup-open” ) $( “.overlay_btn” ).removeClass(“popup-open”); return this; }; })( jQuery ); // if a exists // onclick read button ID value // add “popup-open” class to span with IDvalue as class, […]

使用javascript点击按钮,阅读并显示文本文件内容

单击一个名为“result”的按钮,我想使用java脚本函数读取并显示一个文本文件(存在于我的本地驱动器位置中: C:\ test.txt )并显示test.txt文件内容HTML文本区域。 我是java脚本的新手,有人可以建议java脚本函数的代码来读取和显示.txt文件的内容吗? 谢谢并尊重Deb