首页 \ 问答 \ jquery:添加事件到新创建的元素(jquery: add event to newly created element)

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
更新时间:2022-02-15 19: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)
{    
    return floor(val + 0.5);
}

UPDATE: in response to your comment, sqrt() is defined in math.h

相关问答

更多
  • 实际上,由于旧的和烦人的遗产,几乎没有一个数学函数可以是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-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?
  • 对于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) { ...
  • 您可以使用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.
  • 三角函数 ( 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 ...
  • 尝试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 ...
  • 您可以生成一系列数字,并检查这些数字中的任何一个是否乘以间隔可以得出总分: Enumerable.Range(1,4).Any(i => settings.screenshotintervals * i == scoreTeam1 + scoreTeam2) 对不起,我错过了浮标数值。 正如@Everts所说 - 这里最好的解决方案是Mathf.Approximately用于值比较: var totalScore = scoreTeam1 + scoreTeam2; var result = Enumer ...

相关文章

更多

最新问答

更多
  • 您如何使用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)