stuff.className.indexOf(“term”)== 1不起作用(stuff.className.indexOf(“term”) == 1 not working)
我做了一些谷歌搜索,我发现以下代码不起作用,因为inputs [i] .className不是一个字符串。 我将如何使这个字符串? 我试过toString()。 另外,inputs.length不是0.我检查。
for (var i = 0; i < inputs.length; i++) { if (inputs[i].className.indexOf("blah") == 1) { //do something } }
我想只使用类名为“blah 1; 2; 3; 4”的输入数组值。
任何帮助,将不胜感激。
I did a bit of Googling, and I found that the following code does not work because inputs[i].className is not a string. How would I make this a string??? I tried toString(). Also, inputs.length is not 0. I checked.
for (var i = 0; i < inputs.length; i++) { if (inputs[i].className.indexOf("blah") == 1) { //do something } }
I want to do something with only the inputs array values that have a class name of something like "blah 1;2;3;4".
Any help would be appreciated.
原文:https://stackoverflow.com/questions/13428372
最满意答案
如果你想获得以前的值,你应该使用before触发器而不是after触发器。
触发时间是在过程中发生的阶段。 这可以是BEFORE或AFTER。 如果在此之前使用,则意味着触发器代码将能够处理当前存储在原始状态和新值中的值
If you want to get the previous value, you should use a before trigger instead of an after trigger.
The trigger time is at what stage during the process takes place. This can be either BEFORE or AFTER. If using before this means that the trigger code will be able to work with both the values currently stored in there original state and the new values
相关问答
更多-
如果你想获得以前的值,你应该使用before触发器而不是after触发器。 触发时间是在过程中发生的阶段。 这可以是BEFORE或AFTER。 如果在此之前使用,则意味着触发器代码将能够处理当前存储在原始状态和新值中的值 MySQL触发器:触发时间 If you want to get the previous value, you should use a before trigger instead of an after trigger. The trigger time is at what sta ...
-
如动态sql / Prepared语句所述,这是不可能的。 它将生成Error Code: 1336. Dynamic SQL is not allowed in stored function or trigger 。在尝试甚至CREATE TRIGGER时, Error Code: 1336. Dynamic SQL is not allowed in stored function or trigger 。 关于最接近自动化的是使用CREATE EVENT 。 事件是按照您选择的计划/间隔运行的计划存 ...
-
问题出在这一行: DECLARE VARIABLE NEW_TYPE_ID; 您尚未指定NEW_TYPE_ID的类型,因此该语句不完整,并且该位置的分号是意外的,这会导致令牌未知错误。 DECLARE VARIABLE的语法是: DECLARE [VARIABLE]
{ | | TYPE OF { | COLUMN } [NOT NULL] [CHARACTER SET ] [COL ... -
不幸的是,它是触发器中的逐列比较 编辑:由于不保证100%的准确性,您可以使用CHECKSUM(*) 。 HashBytes更好 Unfortunately, it is a column by column comparison in the trigger Edit: for not guaranteed 100% accuracy, you can use CHECKSUM(*). HashBytes is better
-
在触发器中使用变量(using a variable inside a trigger)[2023-11-11]
你可以设置 Select STH into the_last_inserted_id from TBL limit 1; insert into examination_data (ed_cs_id,ed_examination_id) select cs_id,the_last_insert_id from class_students where cs_class_id = 1 AND cs_year_id = 1; 编辑:@ - 你正在使用而没有声明,只是设置 Select STH into @ ... -
下面的代码对我来说有一些快速测试。 也许它可以满足您的需求。 实际的触发器部分可能是你真正需要的,其余的我用来测试。 这样写的方式,它只会更新当前和相关的记录(当时正在更新的记录)。 连接到inserted表可确保发生这种情况。 使用插入和删除的表(MSDN) CREATE TABLE EmpLog (EmpID int, ShiftStart time, Shiftend time, LogDate date, TotalMinutes decimal(18,2)); GO -- Trigger sta ...
-
有一些小格式错误。 以下可能会被使用,或者: CREATE OR REPLACE TRIGGER Fee_Trigger AFTER UPDATE ON CHARTER FOR EACH ROW WHEN ((NEW.Return_Date <> OLD.Return_Date AND NEW.Return_Date IS NOT NULL)) DECLARE Fee NUMBER; BEGIN Fee := :NEW.Return_Date - :NEW.Due_Date; IF F ...
-
答案是UPDATE事务整体失败。 在tableA.column1更新时,tableA上配置的更新触发器被设计为在tableB上插入新行。 insert语句包含一个在tableB上设置为PK的列。 显然,插入语句不能在PK列中插入重复值,所以整个更新都是轰炸。 对我来说,解决方案是从tableB.PK中删除PK属性。 这是一个审计表,所以我不应该错过它。 谢谢 The answer is that the UPDATE transaction was failing as a whole. The updat ...
-
那么这可能不是最佳选择,但解决此问题的一种方法是使用临时表来存储更改的机器,然后加入到已插入或已删除的表中。 如: ALTER TRIGGER [dbo].[tr_StatusChange_tblMachine] ON [dbo].[tblMachine] AFTER UPDATE AS BEGIN SET XACT_ABORT ON; SET NOCOUNT ON; SET ROWCOUNT 0; CREATE TABLE #tmp(MachineName nvarchar(50), NewStat ...
-
更新tsvector更新触发器(Update tsvector update trigger)[2021-10-06]
您不需要删除列或索引,只需删除并重新创建触发器并更新任何更改的字段。 使用常规DROP TRIGGER语句DROP TRIGGER ,然后使用tsvector_update_trigger使用新列重新创建它,所有这些都在同一事务中。 现在UPDATE tablename SET user_tsv = ... WHERE new_column IS NOT NULL ,如果您已经添加了列,则更新列。 检查tsvector更新触发器的源以找出要在分配中使用的适当表达式。 You don't need to dr ...