按标签名称获取元素[this]?(get element by tag name [this]?)
首先是简短的背景。 所以我刚开始练习使用API。 对于我现在正在使用的那个,我正在加载一个DIV,其中有很多链接,我必须给出一个新的目的。 我设法阻止了默认的onclick-function。 现在我需要保存点击链接“innerHTML”属性。
var nextPage = document.getElementsByTagName("a")[this].innerHTML;
与[this]我试图瞄准点击的链接,但它没有用。 希望你理解我想要做的事情。 如果是这样,有什么办法可以解决这个问题吗?
谢谢!
编辑:
$("#content, a").click(function(event){ event.preventDefault(); var x = document.getElementsByTagName("a")[0].innerHTML; console.log(x) getPage(x); });
First a short background. So I just started practicing using API's. With the one I'm working with right now, I'm loading a DIV which have alot of links in it which I have to give a new purpose. I managed to prevent the default onclick-function. Now I need do save the clicked link "innerHTML" attribute.
var nextPage = document.getElementsByTagName("a")[this].innerHTML;
with [this] I tried to target the clicked link, but it didn't work. Hopefully you understands what I'm trying to do. If so, is there any way I an solve this problem?
Thanks!
EDIT:
$("#content, a").click(function(event){ event.preventDefault(); var x = document.getElementsByTagName("a")[0].innerHTML; console.log(x) getPage(x); });
原文:https://stackoverflow.com/questions/42063997
最满意答案
你正在每行调用getValues,这会占用大量的性能。
最好是进行一次大调用以获取所有数据,然后按顺序执行。var s = SpreadsheetApp.getActiveSheet(); var data = s.getRange(1,4, s.getLastRow()).getValues(); var toAddArray = data.map(function(row, i) { var Valus = row[0].toString(); var newznach = Valus. replace(/\-/g, ""). replace(/[0-9][0-9][0-9][0-9][0-9][a-zA-Zа-яА-Я][a-zA-Zа-яА-Я]/g, ""). replace(/[a-zA-Zа-яА-Я][a-zA-Zа-яА-Я]/g, ""); return [i.toFixed(0), Valus, newznach]; });
You're doing a call to getValues every row, that eats a lot of performance.
It is better to do one big call to have all the data and then go through it sequentially.var s = SpreadsheetApp.getActiveSheet(); var data = s.getRange(1,4, s.getLastRow()).getValues(); var toAddArray = data.map(function(row, i) { var Valus = row[0].toString(); var newznach = Valus. replace(/\-/g, ""). replace(/[0-9][0-9][0-9][0-9][0-9][a-zA-Zа-яА-Я][a-zA-Zа-яА-Я]/g, ""). replace(/[a-zA-Zа-яА-Я][a-zA-Zа-яА-Я]/g, ""); return [i.toFixed(0), Valus, newznach]; });
相关问答
更多-
在你的脚本开始你可以添加。 ini_set('MAX_EXECUTION_TIME', -1); At the beginning of your script you can add. ini_set('MAX_EXECUTION_TIME', '-1');
-
你的循环可能是无止境的。 如果不是,您可以延长最长执行时间,如下所示: ini_set('max_execution_time', 300); //300 seconds = 5 minutes Your loop might be endless. If it is not, you could extend the maximum execution time like this: ini_set('max_execution_time', 300); //300 seconds = 5 minutes ...
-
Google脚本 - 超过最长执行时间,有助于优化(Google script - Exceeded maximum execution time , help optimize)[2023-07-05]
你正在每行调用getValues,这会占用大量的性能。 最好是进行一次大调用以获取所有数据,然后按顺序执行。 var s = SpreadsheetApp.getActiveSheet(); var data = s.getRange(1,4, s.getLastRow()).getValues(); var toAddArray = data.map(function(row, i) { var Valus = row[0].toString(); var newznach = Valus. ... -
多个脚本(项目)是否有助于触发聚合执行时间?(Do multiple scripts (projects) contribute to Trigger Aggregate Execution Time?)[2024-02-22]
显然是每个用户不是ler脚本。 否则配额没有意义。 In the interests of getting some evidence together for this: At 4m25 in this March 2013 episode of Google Apps Unscripted, Kalyan Reddy says that the quotas are "per account type" and as you can see in the dashboard, the Quota tab ... -
你的代码看起来很好,除了你在create函数的循环中的“错误1”(它应该是我i < 12 ,而不是<= 。如果你的脚本到达最后你将有一个undefined月份作为你的month_name在create_months 。 如果你说3-4个月的工作,我建议你只做3个月的时间。 如果你手动运行它。 最简单的解决方案就是等待,然后再次运行,然后再运行,等等 function create1stQuarter() { for( var i = 0; i < 3; ++i ) create_months(y ...
-
首先,在2011年你不使用mysql_query。 您使用mysqli或PDO和准备好的语句。 然后,您不需要弄清楚如何转义SQL的字符串。 你使用了htmlspecialchars ,这是完全错误的。 接下来,您可以使用事务来加速许多插入。 MySQL还支持多种兴趣。 但最好的办法是使用CSV存储引擎。 http://dev.mysql.com/doc/refman/5.0/en/csv-storage-engine.html请阅读此处。 您可以立即将所有内容加载到SQL中,然后根据需要进行操作。 本文还 ...
-
Hhvm无法读取您的配置,因此它采用默认值。 /usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --user www-data --mode daemon -vPidFile=/var/run/hhvm/pid 语法错误,意外的$ end,期望在第79行的/etc/hhvm/server.ini中的TC_DOLLAR_CURLY或TC_QUOTED_STRING或'“'\ n 只需评论任何一行并且效果很好:; hh ...
-
调用db.save(item) 15000次是导致缓慢的原因。 相反,如果您要保存那么多数据,请使用批量操作 。 var db = ScriptDb.getMyDb(); var items = []; for (var row = 1; row < data.length; row++) { var rowData = data[row]; var item = {}; for (var column = 0; column < keys.length; column+ ...
-
问题是在每次迭代中调用SpreadsheepApp与lib相关的方法,如getRange() 。 如上所述: 在脚本中使用JavaScript操作比调用其他服务快得多。 您可以在Google Apps脚本中完成的任何操作都比拨打需要从Google服务器或外部服务器获取数据的内容快得多,例如对电子表格,文档,网站,翻译,UrlFetch等的请求。 如果您可以找到最小化脚本对这些服务的调用的方法,那么您的脚本将运行得更快。 我遇到了同样的情况,而不是像for(i=0;i使用像CBL(MdcB85Ns0dBpktAKfKuamwZpmfj86RiLA)这样的批处理库。 CBL启动触发器在7分钟后启动(startOrResumeContinousExecutionInstance()) 一旦接近5分钟(isTimeRunningOut()),当前索引就是线程存储的 下次运行索引时,将从批处理键加载 我没有测试它,但你可以看到一般的想法 - 你需要更新main()来附加行而不是每次都覆盖。 var FUNCTION_NAME = "main"; var EMAIL_RECIPI ...
相关文章
更多- The content of element type "package" must match "...
- Struts2 Push Tag 引发的问题
- 怎么高效率从Tag 里面抽取有用信息
- 创建标签-git入门教程
- cms中标签的设计与实现
- 操作标签-git入门教程
- 【已解决】Android微信开放平台,申请移动应用的 应用签名 如何获取
- 标签功能发布完成及对cms频道的设计的思考
- HTML5 Audio元素【HTML5教程 - 第五篇】
- android的微信签名
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)