Tag: JavaScript

禁用链接以停止JQuery中的双击

他们被点击一次后,我将如何禁用与button类的所有链接? 我希望能够在一个地方做到这一点,而不必单独改变他们所有的想法? 到目前为止,我得到这个: $("a.button").click(function() { $(this).attr("disabled", "disabled"); }); $("a[disabled]").click(function() { return false; }); 但第二个事件不是射击

为什么很多网站会缩小CSS和JavaScript,而不是HTML?

可能重复: 为什么要削减资产而不是标记? 我看到很多网站使用缩小的CSS和JavaScript来增加网站响应时间,但我从来没有看到任何网站使用缩小的HTML。 为什么你不希望你的HTML被缩小?

如何使用jquery设置单选button选定的值

如何在javascript中设置单选button的select值: HTML代码: <input type="radio" name="RBLExperienceApplicable" class="radio" value="1" > <input type="radio" name="RBLExperienceApplicable" class="radio" value="0" > <input type="radio" name="RBLExperienceApplicable2" class="radio" value="1" > <input type="radio" name="RBLExperienceApplicable2" class="radio" value="0" > ASPX代码 <asp:RadioButtonList ID="RBLExperienceApplicable" runat="server" class="radio" RepeatDirection="Horizontal" EnableViewState="false"> <asp:ListItem Value="1" Text="Yes &nbsp;&nbsp;"></asp:ListItem> <asp:ListItem Value="0" Text="No"></asp:ListItem> </asp:RadioButtonList> <asp:RadioButtonList ID="RBLExperienceApplicable2" runat="server" class="radio" RepeatDirection="Horizontal" EnableViewState="false"> <asp:ListItem Value="1" Text="Yes &nbsp;&nbsp;"></asp:ListItem> <asp:ListItem Value="0" Text="No"></asp:ListItem> </asp:RadioButtonList> […]

函数将时间戳转换为javascript中的人类date

如何将这个时间戳1382086394000转换为2013-10-18 08:53:14在javascript中使用函数? 目前我有这个function: function cleanDate(d) {return new Date(+d.replace(/\/Date\((\d+)\)\//, '$1'));}

Javascript颜色渐变

在有或没有Jquery的情况下使用javascript,我需要根据开始和结束的颜色创build一个渐变颜色。 这是可能的编程方式吗? 最终的颜色只会是开始颜色的深色阴影,并且是无序的列表,我无法控制li项目的数量。 我正在寻找一个解决scheme,允许我select一个开始和结束颜色,将hex值转换为RGB,因此可以在代码中操作。 开始的RGB值通过基于项目数计算的步长值增加。 所以如果列表有8个项目,那么它需要以8个步骤递增分开的红绿蓝值来实现最终的颜色。 有没有更好的方法来做到这一点,如果是的话,我在哪里可以find一些示例代码?

Uncaught TypeError:无法设置未定义的属性“位置”

我有这个代码给我奇怪的错误消息 Uncaught TypeError: Cannot set property 'position' of undefined 这是一个jQuery插件的内部,在popup窗口中显示Google地图。 我在其他地方使用代码,在那里工作得很好 – 唯一的区别似乎是我现在在一个popup窗口中使用它。 我是否缺less范围问题? 像geocoderParams和latlng所有的variables都应该填充。 使用Googlesearch错误消息没有任何价值。 当google.maps.Map()被调用时,错误消息被触发。 self = $(this) self.hide() geocoder = new google.maps.Geocoder geocoderParams = address: self.data('address') || settings.address region: settings.region results = geocoder.geocode geocoderParams, (results, status) -> if status == google.maps.GeocoderStatus.OK latlng = results[0].geometry.location mapOptions = mapTypeControl: false overviewMapControl: false zoom: settings.zoomLevel […]

JavaScript是否提供高分辨率计时器?

JavaScript是否提供高分辨率计时器? 我从零开始写了几个游戏引擎,一些用C语言编写,一些用Java用,一些用Flash。 当谈到animation和交互式graphics时,我总是遵循相同的基本模型。 用下面的devise创build一个基本的类/结构: void init() { /* Called once, preload essential resources here. */ } void update(double time) { /* Updates game/animation state using high resolution time. */ } void render(double time) { /* Updates screen graphics using high resolution time. */ } void run() { double time; init(); while (!done) { time = […]

如何使用敲除来遍历对象(而不是数组)

我想使用类似于Knockout的foreach构造来迭代对象的属性。 这是我正在创造的… 期望的结果 <table> <tr> <td>Name 1</td> <td>8/5/2012</td> </tr> <tr> <td>Name 2</td> <td>2/8/2013</td> </tr> </table> 但是,我的模型看起来像这样… JS function DataModel(){ this.data = ko.observableArray([{ entityId: 1, props: { name: 'Name 1', lastLogin: '8/5/2012' } }, { entityId: 2, props: { name: 'Name 2', lastLogin: '2/8/2013' } }]); } var dataModel = new DataModel(); ko.applyBindings(dataModel); 每行都有一个entityId和道具,它们本身就是一个对象。 此模板不起作用,但是如何将其更改为生成上面所需的表格? 编辑:在这个例子中的props是name和lastLogin […]

document.getElementById(id).focus()不适用于Firefox或Chrome

当我做onchange事件时,它的内部函数validation,但是重点不在于我正在使用document.getElementById('controlid').focus(); 我正在使用Mozilla Firefox和Google Chrome,两者都不起作用。 我不想要任何IE。 任何人都可以告诉我,原因是什么? 提前致谢 代码如下: var mnumber = document.getElementById('mobileno').value; if(mnumber.length >=10) { alert("Mobile Number Should be in 10 digits only"); document.getElementById('mobileno').value = ""; document.getElementById('mobileno').focus(); return false; }

假“点击”来激活一个onclick方法

我有一个onclick方法的元素。 我想在另一个函数中激活这个方法(或者:在这个元素上点击一下)。 这可能吗?