Tag: jQuery

如何select匹配select器的第一个祖先?

将军 : 我如何selectjQuery中元素的第一个匹配的祖先? 例如 : 采取这个HTML块 <table> <tbody> <tr> <td> <a href="#" class="remove">Remove</a> </td> </tr> <tr> <td> <a href="#" class="remove">Remove</a> </td> </tr> </tbody> </table> 我可以通过点击“删除”使用这个jQuery代码删除表中的一行: $('.remove').click(function(){ $(this).parent().parent().hide(); return false; }); 这工作,但它很脆弱。 例如,如果有人把<a>放到<div> ,就会中断。 jQuery中是否有一个select器语法遵循这个逻辑: “这是一个元素,现在find匹配一些select标准的最接近的祖先,并将其返回” 谢谢

如何在多值select中设置select的值在Jquery-Select2中。

大家好我绑定我的下拉与Jquery-Select2。 它的工作正常,但现在我需要通过使用Jquery-Select2绑定我的多值select框。 我的DropDwon <div class="divright"> <select id="drp_Books_Ill_Illustrations" class="leaderMultiSelctdropdown Books_Illustrations" name="drp_Books_Ill_Illustrations" multiple=""> <option value=" ">No illustrations</option> <option value="a">Illustrations</option> <option value="b">Maps</option> <option value="c">Portraits</option> </select> </div> 从这个链接http://ivaynberg.github.com/select2/我使用多值select框,我可以绑定我的dropdwon $("dropdownid").Select2() 它的工作正常,但现在我需要得到select的值到我的下拉编辑模式所以我使用这个例子 $(".Books_Illustrations").select2("val", ["a", "c"]); 它的工作,但我怎么能修复我的select,因为用户可以select任何东西所以我不能写一个,静态这就是为什么我需要dynamic地绑定我的选定值编辑模式。 我想现在你们都清楚我的要求了。 请让我知道,如果你需要进一步清除。

在jQuery UI中缺less图标

我使用的是来自jQuery的模式窗体和小部件 ,但图标不显示。 例如Cross (X)和Plus-Minus (+-)图标。 当我加载页面我等这些错误。 "NetworkError: 404 NOT FOUND – http://127.0.0.1:8000/static/csshttp://img.dovov.comui-bg_flat_75_ffffff_40x100.png" ui-bg_…100.png "NetworkError: 404 NOT FOUND – http://127.0.0.1:8000/static/csshttp://img.dovov.comui-icons_222222_256x240.png" ui-ico…240.png "NetworkError: 404 NOT FOUND – http://127.0.0.1:8000/static/csshttp://img.dovov.comui-bg_highlight-soft_75_cccccc_1x100.png" ui-bg_…100.png 所以,我下载了图像,把它放到指定的path中,然后+- icons出现在最右边两次,而且只有column1小部件被最小化了。 Close X图标仍然不出现。 我哪里错了? 我也想知道如何添加删除小部件function?

我如何dynamic启用/禁用链接与jQuery?

我有一些链接显示在一个页面上。 我想基于页面上的其他事件启用/禁用它们。 有没有办法做到这一点与jQuery?

如何使用jquery查找元素的第n个父元素

我想find给定元素的第n个父元素并访问父元素的属性。 <div id='parent1'><br/> <div id='parent2'><br/> <span><p id='element1'>Test</p></span><br/> </div><br/> <div id='parent3'><br/> <span><p id='element2'>Test</p></span><br/> </div><br/> </div> 我想访问element1的第三个父元素而不使用 $('#element1').parent().parent().parent() 任何帮助,将不胜感激

Ajax请求中的jQuery Ajax请求

是否有可能在另一个Ajax请求内发出ajax请求? 因为我需要一些来自第一个Ajax请求的数据来发出下一个Ajax请求。 首先,我使用Google Maps API获取LAT和LNG,然后使用LAT和LNG请求Instagram API(基于search的位置)。 再一次,这是可能的,如果是这样,怎么样? $('input#search').click(function(e){ e.preventDefault(); var source=$('select[name=state] option:selected').text()+' '+$('select[name=city] option:selected').text()+' '+$('select[name=area] option:selected').text(); var source=source.replace(/ /g, '+'); if(working==false){ working=true; $(this).replaceWith('<span id="big_loading"></span>'); $.ajax({ type:'POST', url:'/killtime_local/ajax/location/maps.json', dataType:'json', cache: false, data:'via=ajax&address='+source, success:function(results){ // this is where i get the latlng } }); } else { alert('please, be patient!'); } });

为什么我在Chrome中收到“jquery.mobile-1.3.2.min.map file not found”消息?

我正在使用这三个CDN文件,正如JQM文档中的build议: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" /> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script> 我很困惑,为什么我在Chrome的“networking”标签下find了404找不到的状态。 似乎是看jQuery的移动min.map文件。 我没有在Firefox中看到这个。 任何想法,为什么它正在寻找这个文件?

如何使用jQuery的change()方法带参数的函数?

我正在使用jQuery版本1.5。 我正在看jQuery的change()函数,特别是在这一点: .change( [ eventData ], handler(eventObject) ) eventData: A map of data that will be passed to the event handler. handler(eventObject): A function to execute each time the event is triggered. 什么是JavaScript中的“数据图”? 我如何使用下面的testing函数作为事件处理程序? var myHandler = function(msg){alert(msg);}; 我试过这个: $("select#test").change(["ok"], myHandler); 和警报报告[object Object]

javascript中的“描述”关键字

所以我是一个JavaScript的新手,我已经经历了别人的代码,我发现这.. describe('deviceready', function() { it('should report that it fired', function() { spyOn(app, 'report'); app.deviceready(); expect(app.report).toHaveBeenCalledWith('deviceready'); }); }); 我不明白的是: describe关键字究竟做了什么? 信息: – 它是一个phonegap应用程序 – 我们正在使用spine.js和jQuery库

jQuery只匹配div的id的一部分

昨天晚上我遇到了一个不寻常的情况。 我只需要匹配id的一部分。 让我以一个例子来清楚你 我有几个divs <div id="sales_info_1">… …… …… …… …</div> <div id="sales_info_2">… …… …… …… …</div> <div id="sales_info_3">… …… …… …… …</div> 和jQuery的喜欢 jQuery("div#dont_know_what_to_write_here").bind("click", function(){ … …… …… …… … }); 我只需要匹配sales_info ,忽略_1,_2或_anything,任何人都可以build议我如何做到这一点? 谢谢