Tag: jQuery

jQuery。数据()不起作用,但.attr()

原谅我没有更具体的这个。 我有这样一个奇怪的错误。 在文档加载后,我循环一些最初有data-itemname=""元素,并使用.attr("data-itemname", "someValue")设置这些值。 问题:当我通过这些元素后来循环,如果我做elem.data().itemname ,我得到"" ,但如果我做elem.attr("data-itemname") ,我得到"someValue" 。 这就像jQuery的.data() getter只获取最初设置为包含一些值的元素,但如果它们本来是空的,然后设置,然后.data()不会稍后获取值。 我一直在试图重新创build这个错误,但一直未能。 编辑 我重新创build了这个错误! http://jsbin.com/ihuhep/edit#javascript,html,live 此外,从上面的链接链接… JS: var theaters = [ { name: "theater A", theaterId: 5 }, { name: "theater B", theaterId: 17 } ]; $("#theaters").html( $("#theaterTmpl").render(theaters) ); // DOES NOT WORK – .data("name", "val") does NOT set the val var theaterA = $("[data-theaterid='5']"); […]

如何在svg元素中使用z-index?

我在这个项目中使用svg圈子, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 120"> <g> <g id="one"> <circle fill="green" cx="100" cy="105" r="20" /> </g> <g id="two"> <circle fill="orange" cx="100" cy="95" r="20" /> </g> </g> </svg> 我在'g'标签中使用z-index来显示元素第一。在我的项目中,我只需要使用z-index值,但我不能使用z-index到我的svg元素。 我GOOGLE了很多,但我没有find任何相对的东西。 所以请帮我在我的svg中使用z-index。 这是DEMO。

JQuery的位置Href?

可能重复: 如何在jQuery / JavaScript中创buildredirect页面? 我记得jQuery中有一个redirect函数。 它就像: $(location).href('http://address.com') 但究竟是什么呢? 我不记得,也找不到Google。

覆盖twitter bootstrap文本框发光和阴影

我想删除文本框和边框的蓝色发光,但我不知道如何覆盖任何js或它的css,请点击这里 编辑1 我想要做到这一点,因为我使用jquery插件标签 ,我也使用twitter引导也插件使用隐藏的textField添加标签,但是当我使用twitter bootstrap它显示为一个文本框发光内有点奇怪的文本框

jQuery:获取从<input type =“file”/>中select的文件名

这个代码应该在IE中工作(甚至不要在Firefox中testing它),但它不。 我想要的是显示附件的名称。 任何帮助? <html> <head> <title>example</title> <script type="text/javascript" src="../js/jquery.js"></script> <script type="text/javascript"> $(document).ready( function(){ $("#attach").after("<input id='fakeAttach' type='button' value='attach a file' />"); $("#fakeAttach").click(function() { $("#attach").click(); $("#maxSize").after("<div id='temporary'><span id='attachedFile'></span><input id='remove' type='button' value='remove' /></div>"); $('#attach').change(function(){ $("#fakeAttach").attr("disabled","disabled"); $("#attachedFile").html($(this).val()); }); $("#remove").click(function(e){ e.preventDefault(); $("#attach").replaceWith($("#attach").clone()); $("#fakeAttach").attr("disabled",""); $("#temporary").remove(); }); }) }); </script> </head> <body> <input id="attach" type="file" /><span id="maxSize">(less than 1MB)</span> </body> </html>

blueimpfile upload插件中的maxFileSize和acceptFileTypes不起作用。 为什么?

我正在使用Blueimp jQueryfile upload插件来上传文件。 我没有上传的问题,但选项maxFileSize和acceptFileTypes不起作用。 这是我的代码: $(document).ready(function () { 'use strict'; $('#fileupload').fileupload({ dataType: 'json', autoUpload: false, acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i, maxFileSize: 5000000, done: function (e, data) { $.each(data.result.files, function (index, file) { $('<p style="color: green;">' + file.name + '<i class="elusive-ok" style="padding-left:10px;"/> – Type: ' + file.type + ' – Size: ' + file.size + ' byte</p>') .appendTo('#div_files'); }); […]

点击或更改使用jQuery的无线电事件

我在我的页面中有一些无线电,而且我想在选中的无线电改变时做一些事情,但是这些代码在IE中不起作用: $('input:radio').change(…); 而谷歌search后,人们build议使用点击 。 但它不起作用。 这是示例代码: <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <script type="text/javascript"> $('document').ready( function(){ $('input:radio').click( function(){ alert('changed'); } ); } ); </script> </head> <body> <input type="radio" name="testGroup" id="test1" />test1<br/> <input type="radio" name="testGroup" id="test2" />test2<br/> <input type="radio" name="testGroup" id="test3" />test3</br> </body> </html> 它也不能在IE中工作。 所以我想知道发生了什么事? 另外,如果我点击一个已经选中的收音机,恐怕它会重新触发变化事件。 更新: 我不能添加评论,所以我在这里回复。 我使用IE8和链接Furqan给我也不能在IE8中工作。 我不知道为什么…

jQuery按值select选项元素

我有一个由span元素包装的select元素。 我不被允许使用selectID,但我被允许使用span id。 我正在尝试编写一个javascript / jquery函数,其中input是一个数字我是select的选项的值之一。 该function将相关选项转为选中状态。 <span id="span_id"> <select id="h273yrjdfhgsfyiruwyiywer" multiple="multiple"> <option value="1">cleaning</option> <option value="2">food-2</option> <option value="3">toilet</option> <option value="4">baby</option> <option value="6">knick-knacks</option> <option value="9">junk-2</option> <option value="10">cosmetics</option> </select> </span> 我写了如下(这不完全工作,这就是为什么我发布这个问题): function select_option(i) { options = $('#span_id').children('select').children('option'); //alert(options.length); //7 //alert(options[0]); //[object HTMLOptionElement] //alert(options[0].val()); //not a jquery element //alert(options[0].value); //1 //the following does not seem to work since […]

JQUERY UI Accordion开始折叠

我怎样才能使jquery UI手风琴开始折叠窗体加载时。 有没有JavaScript的代码呢?

通过使用jQuery文本设置下拉列表值

我有一个下拉为: <select id="HowYouKnow" > <option value="1">FRIEND</option> <option value="2">GOOGLE</option> <option value="3">AGENT</option></select> 在上面的下拉列表中,我知道下拉列表的文字。 如何设置document.ready下拉的值与使用jquery的文本?