jquery-selectors

Problems extracting parts from rendered HTML tables with jQuery

北城以北 提交于 2020-01-16 18:55:08
问题 I need to grab certain parts from many tables, save them and finally generate a new table using a jQuery template. But I am having problems collecting the first value. HTML <table> <tr><td colspan="7"><a href="http://link/index.php?view=page&id=2961" target="_blank" title="title">atext1 atext2</a> - stuff 2 - <img src="img/icon_1.gif" class="icon" title="icon1" />12 - <img src="img/icon_2.gif" class="icon" title="icon2" />4 - <span title="long title"><img src="img/icon_3.gif" class="icon" />

jQuery's .end() doesn't work as expected after .contents()?

偶尔善良 提交于 2020-01-16 18:02:21
问题 a = $("table").clone().find("p:has(input)").contents().not("span:has(input:checked)").remove().end().text() b = $("table").clone().find("p:has(input)").contents().not("span:has(input:checked)").text() c = $("table").clone().find("p:has(input)").contents().not("span:has(input:checked)").empty().end().text() d = $("table").clone().text() $("#a").text(a) $("#b").text(b) $("#c").text(c) $("#d").text(d) <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

jQuery's .end() doesn't work as expected after .contents()?

早过忘川 提交于 2020-01-16 18:01:25
问题 a = $("table").clone().find("p:has(input)").contents().not("span:has(input:checked)").remove().end().text() b = $("table").clone().find("p:has(input)").contents().not("span:has(input:checked)").text() c = $("table").clone().find("p:has(input)").contents().not("span:has(input:checked)").empty().end().text() d = $("table").clone().text() $("#a").text(a) $("#b").text(b) $("#c").text(c) $("#d").text(d) <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

Trying to generate an array from jQuery :checked selector

随声附和 提交于 2020-01-16 15:35:57
问题 I have a table like this: <tr class="row"> <td class="row-checkbox-delete-row"> <input tabindex="-1" class="checkbox-delete-row" type="checkbox" /> </td> <td class="row-target">10</td> <td class="row-product-id"> <input class="id-target row-product-id" name="lineItem[0].originalInput" type="text" data-ajax-line-id="1" /> </td> <td class="row-qty"> <input class="qty-target row-qty" name="lineItem[0].quantity" type="text" value="1" /> </td> <td class="row-description"></td> <td class="row-abc6"

Get height of multiple divs with jquery

我是研究僧i 提交于 2020-01-16 01:13:12
问题 I need to get the height of three divs, add them together and see if the scroll position is great than that number. Right now I am able to get the height of one element, but how could I add others in? Basically, I want to write "if scroll_top is greater than the height of div 1 + div 2 + 3" var scroll_top = $(window).scrollTop(); if ((scroll_top > $('.nav-bar-fixed').height()) { alert('sometext'); } 回答1: Try this: $(document).ready(function() { var limit =$('.myEle1').height() + $('.myEle2')

How to prevent jQuery hover event from firing when not complete?

喜夏-厌秋 提交于 2020-01-15 08:48:18
问题 Here is where I am having difficulty: $('div.sidebar_content_con').hover(function () { $(this).children('.sidebar_details_container').slideDown(500, function() { $(this).children('.sidebar_details, .sidebar_click').fadeIn(500); }); },function(){ $(this).children('.sidebar_details_container').slideUp(500) $('.sidebar_details, .sidebar_click').fadeOut(500); }); The problem is that multiple hover events can fire while the slideDown and fadeIn animations are occurring. Ideally, only one hover

What is the difference between the descendant selector and the :has selector in jQuery?

这一生的挚爱 提交于 2020-01-15 03:49:18
问题 What is the difference between the Descendant selector and the :has selector? From the documentation: Descendant selector Description: Selects all elements that are descendants of a given ancestor. A descendant of an element could be a child, grandchild, great-grandchild, and so on, of that element. :has Description: Selects elements which contain at least one element that matches the specified selector. The expression $('div:has(p)') matches a <div> if a <p> exists anywhere among its

How to remove all the <tr> from a table except the first one using jquery

北战南征 提交于 2020-01-14 12:50:05
问题 I am having a table and I want to remove all <tr> of the table except the first one. How can I do this.? 回答1: There are several methods here, the most terse is to use the :gt() selector, like this: $('#tableID tr:gt(0)').remove(); 回答2: Is there a special meaning to the first row? I am going to go out on a limb and say the first row is likely the row which contains the column headings. If so, one easy option is to put the first row in a <thead> and all the body rows in a <tbody> . Then you

nth-child and descendant selector not selecting all expected elements

为君一笑 提交于 2020-01-14 04:13:06
问题 My DOM is as follows: http://jsfiddle.net/pimvdb/AHJXk/1/. <table> <tr> <td> <input type="text"><input type="text"> </td> <td> <input type="text"><input type="text"> </td> </tr> <tr> <td> <input type="text"><input type="text"> </td> <td> <input type="text"><input type="text"> </td> </tr> </table> I'm trying to select all input s in the second td of each tr , i.e. four in total. I thought the following selector would work: $('table tr td:nth-child(2) input') But it only returns the first input

jQuery get all images within an element larger than a specific size

爷,独闯天下 提交于 2020-01-12 20:57:45
问题 So I have an image placeholder and I want to load the first image from the HTML within a DIV element that is larger than 70px width or height. Then provide a next and previous link to load the next image that is larger than 70px. I know jQuery has a next & prev selector but I'm not sure how I would tie this in with next and previous links or specify an image size. 回答1: To get all images larger that some size you can use something like this: var allImages = $('img', yourDivElement) var