草庐IT

Find-Replace

全部标签

javascript - 如何优化$.find().first()?

我需要检索第一个元素。我用这段代码来做...$(element).find('.x').first();据我了解,该代码...从element中检索与.x匹配的所有元素,删除不需要的元素;有没有更好的方法呢?像$.findOne()之类的? 最佳答案 根据jQuery文档:Because:firstisajQueryextensionandnotpartoftheCSSspecification,queriesusing:firstcannottakeadvantageoftheperformanceboostprovidedbyt

javascript - ember-data - store.find ('model' ) 总是查询服务器

详细信息:ember-data-1.0.0.beta.3和默认的RESTAdapter我可能误解了store.find()方法的工作原理,但是,据我了解,如果我要查询的记录已经存在于商店:varIndexRoute=Em.Route.extend({model:function(){returnthis.store.find('link');},});来自DS.Store.find()的emberjs.com文档:Thefindmethodwillalwaysreturnapromisethatwillberesolvedwiththerecord.Iftherecordwasalre

javascript - UnderscoreJS 未捕获类型错误 : Cannot call method 'replace' of undefined

在我的BackboneView中我有:noteTemplate:_.template($('#note-template').html()),这是抛出这个错误。模板是:Created3daysagoIn3hours我很困惑,因为这在我的控制台中有效:>>_.template($('#note-template').html());函数(n){returne.call(this,n,w)}完整代码如下:App.Views.Index=Backbone.View.extend({el:$("div.reminders"),todays:$("span.today"),tomorrows:$

javascript - HTML5 Canvas : find out if click co-ordinates are inside a given rectangle

可能有人在这个困境上有过类似的经历,可以帮助我走出困境......基本上,我有一个Canvas元素,我使用在循环中绘制几个矩形context.fillRect(x,y,width,height)现在,我希望一些矩形成为热点并响应点击事件。我可以使用event.layerX和event.layerY找出点击事件的确切(x,y)。鉴于我知道以下内容:点击的确切x,y每个矩形的x、y、宽度和高度我如何确定点击事件是否发生在某个矩形的周边内?并且,点击事件发生在哪个矩形0n?有类似的数学公式吗?任何帮助将不胜感激,如果我不够清楚,请告诉我......谢谢编辑没有比遍历所有矩形并检查它们的位置和

javascript - typescript 错误 : TS2304: Cannot find name '$'

声明x=$('#msgBox_'+scope.boxId).position().left;生成一个errorTS2304:Cannotfindname'$'尽管jquery和@types安装在node_modules文件夹中。我的tsconfig.json看起来像这样:{"compilerOptions":{"module":"commonjs","target":"es5","sourceMap":true,"moduleResolution":"node","declaration":true},"exclude":["node_modules"]}我该如何解决?

Javascript:替代 Array.prototype.find()?

当我在AngularJS中使用Chrome浏览器时,我遇到了.find()无法正常工作的问题。这是我最初的问题:AngularJS:Array.prototype.find()doesnotworkinChrome这条线失败了:console.log($scope.products_colors);//prints`[Object]0:Objectlength:1__proto__:Array[0]concat:functionconcat(){[nativecode]}constructor:functionArray(){[nativecode]}every:functioneve

javascript - knockout : find out which observable triggerred computed

我有一个包含多个可观察对象的对象。有没有办法在计算中知道哪些可观察的变化,从而知道哪个可观察的触发了计算?提前谢谢你马修 最佳答案 在没有详细说明您要实现的目标的情况下,我会发布此内容,希望它能有所帮助。跟踪更改的一种简单方法是对要跟踪的可观察对象使用.subscribe方法。每次更新observable时,都会触发此方法。self.myValue=ko.observable('initialvalue');self.myValue.subscribe(function(item){alert('myValuehaschangedt

javascript - TypeError : str. replace is not a function strange error with vue.js Ajax 调用

我收到一个奇怪的错误:vue-resource.common.jsUncaughtTypeError:str.replaceisnotafunction它似乎与我正在获取一些的ajax调用有关数据:exportdefault{data:()=>({recipes:[]}),ready(){this.$http.get('http://localhost:3000/recipes',{headers:{'Access-Control-Allow-Origin':true}}).then((recipes)=>{this.$set('recipes',recipes)})}};我是vue.

Find() 的 Javascript 代码优化

我有C#代码在SQL中运行查询并返回大约2000行。然后创建一个Treeview控件并将其添加到我的主页。这几乎是立即完成的,这很好。varorgId=$('select[name="ctl00$PageContent$FunctionsDropDownList"]option:selected').val();if(!orgId){returnfalse;}//callsserversidegetdata//Thislinehappensquickly$('#ctl00_PageContent_HiddenRulesDialogTriggerButton').click();//Th

javascript - Chrome 扩展 : How can I show the find bar and supply text for it?

我正在制作一个扩展程序,将当前事件网页中的选定文本存储到本地存储中,然后当用户在我的扩展程序的弹出窗口中单击该选定文本时,该扩展程序将触发chrome.tabs.create并打开网站选定的文本被选中。这些功能有效,但我不知道如何在新选项卡打开时触发“查找”功能。我希望新创建的选项卡高度显示我的扩展程序存储的选定文本。我认为有两种方法可以做到这一点......以某种方式触发浏览器默认具有的“查找”功能。带有“Ctrl+F”或“Command+F”的触发并在其中插入所选文本通过突出显示所选文本来编辑新创建页面的HTML。new_source={"url":tab[0].url,"titl