each

Extract table row data with button on that row with jQuery each()

蓝咒 提交于 2019-12-11 12:48:22
问题 TLDR I want my script below to return the <input id and value of the table row that the button clicked is in. Right now it always returns the info from the first row only, regardless of which row the button was in. I think what I'm looking to do is simple, and I think I'm pretty close. But this is all a learning process for me so it's possible probable that I'm making a beginner mistake. I'm building a shopping cart. I have table rows that are built in a foreach loop. The basic gist is such

Unexpected array output on page [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-12-11 11:20:08
问题 This question already has answers here : What is the difference between <%, <%=, <%# and -%> in ERB in Rails? (7 answers) Closed 7 months ago . I'm listing a set of data (for simplicity sake, just the identity column) of a particular database table table as follows: <%= @fields.select{|field| field.model=="PreferredOffering"}.each do |field| %> <%= field.id %> <br/> <% end %> As you may have gathered from above, I'm using the combination of select and each to iterate ONLY through rows whose

jQuery xml parse with check for IE8 not working

本小妞迷上赌 提交于 2019-12-11 08:26:51
问题 I have looked through and tried all the SO answers on jQuery, XML and IE8, but nothing is giving me a result. Any other suggestions on how to get this to working with jQuery or Javascript? $.ajax({ type: "GET", url: "http://query.yahooapis.com/v1/public/yql?q=select%20title%2C%20link%20from%20rss%20where%20url%3D%22http%3A%2F%2Fwww.fs.usda.gov%2Fwps%2FPA_WIDConsumption%2Frssgetfile%3FxFSENavChannel00%3D1109%26xFSENavChannel02%3D091000000000000%26pathinfo%3D%2Fwps%2Fportal%2Ffsinternet%2F!ut

jquery compare the height beneath img to h2's height

好久不见. 提交于 2019-12-11 08:18:49
问题 I am trying to adapt this: var h2=$('.block h2'); var divh=$('.block').height(); while ($(h2).outerHeight()>divh) { alert('enters while'); $(h2).text(function (index, text) { return text.replace(/\W*\s(\S)*$/, '...'); }); } as explained here: Cross browsers mult-lines text overflow with ellipsis appended within a width&height fixed div? The problem I have encountered in my case is that I have various li where each one contains a .block which has a h2 tag per li Example: <li> <div class="block

jQuery $.each loop and json data

。_饼干妹妹 提交于 2019-12-11 06:54:57
问题 I can't seem to get this working, i am retrieving some json data, and just trying to loop through it an append it to a DIV. here is my code: HOW THE JSON IS RETURNED (PHP) {"list":[{"subscribe":"example"},{"subscribe":"example2"},{"subscribe":"example3"},{"subscribe":"example4"},{"subscribe":"example5"}]} MY JSON CALL USING JQUERY $.getJSON("article.php",function(data) $.each(data.list, function(i,data) { var listData = "<li>" + data.subscribe + "</li>"; $('#lists').append(listData); }); });

jQuery: check if column contains certain value

孤人 提交于 2019-12-11 06:23:40
问题 I have a standard table that contains various values. The same value may appear in different TDs but not within the same column. Example: <table id="myTable"> <tr> <td>text1</td> <td>text2</td> <td>text3</td> </tr> <tr> <td>text4</td> <td>text5</td> <td>text6</td> </tr> <!--more TRs...--> </table> Is there a way I can use jQuery to check whether a certain column contains a certain value and return 1 if yes or 0 if no ? Example: When applying this to the second column above and check for "

jquery ajax load method: only one request for multiple elements?

廉价感情. 提交于 2019-12-11 06:19:33
问题 Hey, I have 10 "ul.rating" elements on my page. I want to refresh those elements every minute. var reload = 60000; var currentpage = window.location; setInterval(function() { $('ul.ratings').load(currentpage + " .ul.ratings >*", function() { //callback }); }, reload); Now I have the following two problems. I need to find away to reload each element new. Right now I'm probably reloading the SAME ul.ratings element for all ul.ratings elements on my page. So there must be some way to use index()

Random Images on page load

偶尔善良 提交于 2019-12-11 05:48:21
问题 I am currently building a site whereby they would like each image on load to display different images. I have so far been able to target these and randomise them but it is applying the same image to all of the items. If you could see where I'm going wrong it would be great var description = [ "http://placehold.it/300x300", "http://placehold.it/200x200", "http://placehold.it/100x100" ]; var size = description.length var x = Math.floor(size*Math.random()) $('.item img').each(function() { if($(

Rewrite JSON structure and include an EACH loop in Rails

假如想象 提交于 2019-12-11 05:12:44
问题 I have a list of shows in a database that need to be output in a certain JSON style in order to work with Polymaps. Part of this includes the need to iterate over one section in order to create a list of points. I'm pretty certain that this needs to be achieved using :include in the render :json => @results bit of the code. Here's the code as it stands: def gigs @gigs = Show.where(:displayname => "Vans Warped Tour 2011") @giggage = [{ :type => "FeatureCollection", :features => [ @gigs.each do

need to get the 'a' name for each .post for the plugin

為{幸葍}努か 提交于 2019-12-11 05:09:25
问题 (function ($) { 'use strict'; var url = window.location.href.split('#')[0]; var post = $('.post').children('a[name]').attr('name'); var helpers = { "defaults": { "post": post, "href": url+'#', "send": 'true', "layout": 'button_count', "width": '125', "faces": 'false', "font": 'verdana', "action": 'like', "scheme": 'light', }, "init": function (options) { var settings = $.extend({}, helpers.defaults, options), easyface = $('<div />').addClass('easyface fb-like').attr({ "data-href": settings