jquery:添加事件到新创建的元素(jquery: add event to newly created element)
我通过jquery添加了一个新元素。 现在我想要一个函数来触发元素被点击。 我知道这有很多答案,但他们似乎不适合我。 不知道我在这里做错了什么。
我努力了:
new_ele = "<a>click me</a>" new_ele.click(function() {alert('xxxx');}); other_ele.append(new_ele);
这在添加new_ele之前失败。
我也尝试过(而不是上面的第二行)
new_ele.onclick = function() { alert('blah'); };
这附加元素,但是当我点击时没有任何反应。
和
new_ele.on('click',function() {alert('ddd');});
在添加元素之前,这也失败了。
I have added a new element via jquery. Now I want a function to trigger when the element is clicked. I know there are many answers to this, but they don't seem to work for me. Not sure what I am doing wrong here.
I have tried:
new_ele = "<a>click me</a>" new_ele.click(function() {alert('xxxx');}); other_ele.append(new_ele);
This fails before the new_ele is appended.
I have also tried (instead of the second line above)
new_ele.onclick = function() { alert('blah'); };
This appends the element, but nothing happens when I click.
And
new_ele.on('click',function() {alert('ddd');});
This also fails before the element is appended.
原文:https://stackoverflow.com/questions/12757295
最满意答案
对于Windows库,
math.h
中不存在Round()
。 定义:static inline double round(double val) { return floor(val + 0.5); }
更新:在回应你的评论时, sqrt()在
math.h
定义
Round()
does not exist inmath.h
for the Windows libraries. Define:static inline double round(double val) { return floor(val + 0.5); }
UPDATE: in response to your comment, sqrt() is defined in
math.h
相关问答
更多-
Constexpr数学函数(Constexpr Math Functions)[2022-04-05]
实际上,由于旧的和烦人的遗产,几乎没有一个数学函数可以是constexpr ,因为它们都具有在各种错误条件(通常是域错误)上设置errno的副作用。 Actually, because of old and annoying legacy, almost none of the math functions can be constexpr, since they all have the side-effect of setting errno on various error conditions, u ... -
在GNU libm中,执行sin是依赖于系统的。 因此,您可以在每个平台的相应子目录sysdeps的某处找到该实现。 一个目录包括由IBM贡献的C中的一个实现。 自2011年10月以来,这是在典型的x86-64 Linux系统上调用sin()时实际运行的代码。 它显然比fsin装配说明快。 源代码: sysdeps / ieee754 / dbl-64 / s_sin.c ,寻找__sin (double x) 。 这段代码非常复杂。 没有一个软件算法尽可能快,并且在x值的整个范围上也是准确的,因此库实现了 ...
-
Logstash中的数学函数(Math functions in Logstash)[2021-11-11]
logstash-filter-math不是核心插件,但可以在这里找到 。 您可以按顺序执行后续步骤或安装它: > git clone https://github.com/robin13/logstash-filter-math.git > cd logstash-filter-math > gem build > $LS_HOME/bin/logstash-plugin install logstash-filter-math-0.2.gem 如果您不想为此安装第三方插件,您还可以使用ruby过滤器轻 ... -
对不起,我找到了答案。 我只需要这样写: std :: max std :: sqrt 但是为什么在Windows操作系统下没有“std ::”会有效? Sorry I found the answer. I just need to write it this way: std::max std::sqrt But Why does it work without "std::" under Windows OS?
-
C:数学函数?(C: Math functions?)[2023-01-02]
对于Windows库, math.h中不存在Round() 。 定义: static inline double round(double val) { return floor(val + 0.5); } 更新:在回应你的评论时, sqrt()在math.h定义 Round() does not exist in math.h for the Windows libraries. Define: static inline double round(double val) { ... -
Javascript数学函数(Javascript Math Functions)[2022-03-25]
您可以使用each() (docs)循环来处理每个单独的输入。 点击这里测试一个工作示例。 (的jsfiddle) $('a.square').click(function() { $('#myform :text').each(function() { this.value *= this.value; }); }); $('a.square_root').click(function() { $('#myform :text').each(function() ... -
任何标准头允许包含任何其他标准头。 Any standard header is allowed to include any other standard header.
-
如何修复数学函数(How to fix math functions)[2022-07-16]
三角函数 ( Sin , Cos等)周期为2π ( 2 * Math.PI )。 但是,由于Math.PI是double 1e27 数字 ,因此只有16-17个正确的数字 ,所以您无法通过天真计算1e27 (我们需要至少27位数字 ): Double result = Math.Cos(1e27); // totally wrong. 要执行任务,您需要首先获得适当的pi值,例如从此处开始 http://www.piday.org/million/ 我们还必须与BigInteger : int e ... -
C#中的数学函数(Math Functions in C#)[2022-07-02]
尝试Dew Research的Stats Master 。 BetaFit UniformFit Thanks. I also got this http://www.meta-numerics.net/Documentation/html/8ff81058-d821-cfa0-eccf-b0c21d66a0a3.htm Meta.Numerics also contains some classes which solves my problem. There is a static function F ... -
数学函数c#统一(math functions c# in unity)[2022-02-22]
您可以生成一系列数字,并检查这些数字中的任何一个是否乘以间隔可以得出总分: Enumerable.Range(1,4).Any(i => settings.screenshotintervals * i == scoreTeam1 + scoreTeam2) 对不起,我错过了浮标数值。 正如@Everts所说 - 这里最好的解决方案是Mathf.Approximately用于值比较: var totalScore = scoreTeam1 + scoreTeam2; var result = Enumer ...