jQuery to loop through dynamically created elements with the same class

I have no. of div which is created dynamically in button click. <table> <tbody id="ProductDetail"></tbody> </table> In button click, some no. of div are created with Amount value. funtion createDiv(){ $("#ProductDetail").append("<tr><td ><div class='Amount'>"+Amount+"</div></td></tr>"); } I want to loop through these dynamical

jQuery使用相同的类来动态创建元素

我没有。 div是在按钮点击动态创建的。 <table> <tbody id="ProductDetail"></tbody> </table> 在按钮点击,一些没有。 的div创建与金额值。 funtion createDiv(){ $("#ProductDetail").append("<tr><td ><div class='Amount'>"+Amount+"</div></td></tr>"); } 我想循环这些动态创建的div来获取jquery中的Amount值。我在代码下面尝试。 但它不是迭代循

Passing values from a DIV element to an input

I have a PHP calendar form (generated from http://style-vs-substance.com/code/calendar-class-php/ as a base, but heavily customised and updated) which outputs two month at a time - 30/31 days, in a tabular format. What I am trying to create is a booking form for business meetings, whereby the client user can click on a date on the HTML calendar and the value of the date as in the whole date val

将值从DIV元素传递到输入

我有一个PHP日历表格(从http://style-vs-substance.com/code/calendar-class-php/生成,作为基础,但大量定制和更新),每次输出两个月 - 30/31天,以表格的形式。 我正在尝试创建的是商务会议的预订表单,客户用户可以在HTML日历上点击日期,并在整个日期值中单击日期的值 - 而不仅仅是将日期传递给输入字段。 我想实现类似(伪代码):(2015年3月的日历月) <td><div value='13032015' id='something'>1

Query classnames of checked items as array?

This question already has an answer here: jQuery to loop through elements with the same class 14 answers You need to iterate all the :checked checkboxes, here you can use .map() var clss=$("[class*='observedType']:checked").map(function(){ return $(this).attr('class') }).get(); Updated Fiddle I would recommend you to use custom data-* prefix custom attribute to store the arbitrary data

将检查的项目的类名称查询为数组?

这个问题在这里已经有了答案: jQuery使用相同的类14个答案来遍历元素 你需要遍历所有:checked复选框,在这里你可以使用.map() var clss=$("[class*='observedType']:checked").map(function(){ return $(this).attr('class') }).get(); 更新小提琴 我建议你使用自定义data-*前缀自定义属性来存储任意数据。 <input type="checkbox" id="cb_31" class="observedType" data-type="observedType1"> 可以使用.da

Access multiple items with same name in DOM

This question already has an answer here: jQuery to loop through elements with the same class 14 answers You can iterate through the collection of items with .each() : $(".license-box pre").each(function() { console.log("this <pre> contains: " + $(this).text()); }); The callback to .each() is passed the index, which would let you do something like act only on the even-indexed elemen

在DOM中访问多个具有相同名称的项目

这个问题在这里已经有了答案: jQuery使用相同的类14个答案来遍历元素 您可以使用.each()遍历项目集合: $(".license-box pre").each(function() { console.log("this <pre> contains: " + $(this).text()); }); 对.each()的回调传递给索引,它可以让你在只有偶数索引的元素上执行类似的操作: $(".license-box pre").each(function(index) { if ((index & 1) === 0) console.log("even <pre>: "

How to loop through each image with the same class name?

Possible Duplicate: jQuery to loop through elements with the same class I am trying to loop through my images that have a class. for(var i=0; i<sizes.length; i++){ var imageSize=sizes[i]; $('.image').width(imageSize); } I have 10 images with the same class name, however, I want them to have different image size. The loop will loop 10 times but I am not sure how to make each ima

如何循环使用相同类名的每个图像?

可能重复: jQuery循环通过具有相同类的元素 我试图循环播放我的图像,有一个类。 for(var i=0; i<sizes.length; i++){ var imageSize=sizes[i]; $('.image').width(imageSize); } 我有10个具有相同类名的图像,但是,我希望它们具有不同的图像大小。 循环将循环10次,但我不确定如何使每个图像具有特定的图像imagesize 。 任何人都可以帮助我吗? 我的大脑几乎是鱼苗。 非常感谢! 如果所有图像都有一类

correct syntax for pure javascript

I have this code: function render(str) { var main = document.createElement('div'); with(main.style) { //style stuff here } main.appendChild(document.createTextNode(str)); document.body.appendChild(main); setTimeout(function(){ try{ document.body.removeChild(main); } catch(error){} },5000); } This render a message inside a

纯JavaScript的正确语法

我有这样的代码: function render(str) { var main = document.createElement('div'); with(main.style) { //style stuff here } main.appendChild(document.createTextNode(str)); document.body.appendChild(main); setTimeout(function(){ try{ document.body.removeChild(main); } catch(error){} },5000); } 这会在div内显示一条消息,然后

laravel 5.4: how to pass value from javascript to controller for updating data

I am new to laravel. I want to update a database row. For this purpose, i want to pass the id of the corresponding row to the controller from javascript. I can get the id in javascript file from view. But i get an error ( ErrorException in PatientController.php line 80: Creating default object from empty value) while doing this. Because controller does not get that id. How can i pass the id

laravel 5.4:如何将javascript值传递给控制器​​以更新数据

我是laravel新手。 我想更新一个数据库行。 为此,我想将相应行的id从javascript传递给控制器​​。 我可以从视图中获取JavaScript文件中的id。 但是,在执行此操作时,出现错误(PatientController.php中的ErrorException第80行:从空值创建默认对象)。 因为控制器没有得到该ID。 我如何通过身份证并解决此问题? 我的看法(editPatientView.blade.php): <div class="patient-form-view" data-patientid="{{ $patie

Using GET instead of POST

Ran into an issue where I need to use GET vs POST on a form method, but GATC cookie data is not being appended to the URL correctly, because the form's data is trumping Google's GATC data (using linkByPost). I've read up on a potential solution posted here, but seems like an insane amount of work to make GET behave. I also stumbled upon another solution here, but IE doesn't res

使用GET而不是POST

进入一个问题,我需要在窗体方法上使用GET和POST,但是GATC cookie数据没有被正确地附加到URL上,因为表单的数据在使用Google的GATC数据(使用linkByPost)。 我已经阅读了这里发布的一个可能的解决方案,但似乎是让GET表现出疯狂的工作量。 我也在这里偶然发现了另一个解决方案,但是IE在URL的'anchor'部分之后并不尊重任何东西。 任何人有任何其他想法? 如果我不能通过JS处理这个问题,我将不得不进入处理表单

Submitting a form (post, NOT ajax) with some additional parameters

I need to perform a non-ajax post by clicking the submit of a form. Before submiting I have to add some additional form parameters. Here is how I do this: $("#my_form").on("submit", function (e) { e.preventDefault(); var data = $(this).serializeArray(); data.push({"name": "extra data1", "value": "extra value 1"}); var params = $.param(data); //what's next? //$.post($(

用一些附加参数提交表单(post,NOT ajax)

我需要通过单击提交表单来执行非Ajax帖子。 提交之前,我必须添加一些额外的表单参数。 以下是我如何做到这一点: $("#my_form").on("submit", function (e) { e.preventDefault(); var data = $(this).serializeArray(); data.push({"name": "extra data1", "value": "extra value 1"}); var params = $.param(data); //what's next? //$.post($(this).attr("action"), data: params); // ajax req

How to add a hidden list of IDs to a form in Javascript?

I've got a simple form in html: <form action="" method="post"> <input id="title" name="title" size="30" type="text" value=""> <input type="submit" value="Save this stuff"> </form> I also have a file upload on the page, which handles uploads using ajax and adds the files to a mongoDB. The file upload returns the mongoDB id of the file (for example 12345 ) and

如何在Javascript中添加隐藏的ID列表到表单中?

我在html中有一个简单的表单: <form action="" method="post"> <input id="title" name="title" size="30" type="text" value=""> <input type="submit" value="Save this stuff"> </form> 我在页面上也有一个文件上传,它使用ajax处理上传并将文件添加到mongoDB。 文件上传返回文件的mongoDB标识(例如12345 ),我想将该标识添加到表单中作为隐藏字段,以便在提交表单时将该标识发布到服