jquery-selectors

jQuery Select box multiple option get value and match values

左心房为你撑大大i 提交于 2021-02-20 05:16:31
问题 I have same classname multi select box with same values in body, what I want if use chose value 1 from first or any select box then that value 1 on all other select box option will disable so user can't choose the same value in other multi select box. <select name="mySel" class="myselect" multiple="multiple"> <option value="val1">option 1</option> <option value="val2">option 2</option> <option value="val3">option 3</option> <option value="val4">option 4</option> </select> <select name="mySel"

jQuery Select box multiple option get value and match values

走远了吗. 提交于 2021-02-20 05:16:07
问题 I have same classname multi select box with same values in body, what I want if use chose value 1 from first or any select box then that value 1 on all other select box option will disable so user can't choose the same value in other multi select box. <select name="mySel" class="myselect" multiple="multiple"> <option value="val1">option 1</option> <option value="val2">option 2</option> <option value="val3">option 3</option> <option value="val4">option 4</option> </select> <select name="mySel"

Selecting numbers with jQuery

北战南征 提交于 2021-02-18 08:22:27
问题 In a given DIV I wish to apply a SPAN to all numbers and only them. Is there a way to select numbers with jQuery ? 回答1: jQuery doesn't provide native selectors for text, but it is possible to achieve that effect. I adapted this from my answer to a previous question, designing it to not mangle any links with numbers in the URL (jsFiddle demo): function autospan() { var exp = /-?[\d.]+/g; $('*:not(script, style, textarea)').contents().each(function() { if (this.nodeType == Node.TEXT_NODE) { var

How to check if all siblings (including selected) are checked with jQuery?

ε祈祈猫儿з 提交于 2021-02-11 07:21:33
问题 I'm trying to get only siblings of selected element but can't find a proper method for this or a way to achieve it. I always get the whole tree with find() method and with children() I can't get it to work. This clicking should work like a checkbox tree: If you click parent all children should be clicked and if you uncheck parent, all children must be unchecked. But the thing that doesn't work is if you check a checkbox and all siblings are not clicked then the parent must indeterminate! And

How to check if all siblings (including selected) are checked with jQuery?

雨燕双飞 提交于 2021-02-11 07:20:43
问题 I'm trying to get only siblings of selected element but can't find a proper method for this or a way to achieve it. I always get the whole tree with find() method and with children() I can't get it to work. This clicking should work like a checkbox tree: If you click parent all children should be clicked and if you uncheck parent, all children must be unchecked. But the thing that doesn't work is if you check a checkbox and all siblings are not clicked then the parent must indeterminate! And

How to obtain only visible elements inside an HTML table using jQuery?

让人想犯罪 __ 提交于 2021-02-10 04:17:27
问题 I have the following problem: I have a table in which each row has some cells that are visible, and some that aren't. Something like this: <table> <thead> </thead> <tbody> <tr> <td id='cell_a1'>A</td> <td id='cell_b1' style='display:none'>B</td> </tr> <tr> <td id='cell_a2'>C</td> <td id='cell_b2' style='display:none'>D</td> </tr> </tbody> </table>` And I need to retrieve only the table's visible content using the .html() method, like this for the table above: <table> <thead> </thead> <tbody>

How to obtain only visible elements inside an HTML table using jQuery?

最后都变了- 提交于 2021-02-10 04:16:31
问题 I have the following problem: I have a table in which each row has some cells that are visible, and some that aren't. Something like this: <table> <thead> </thead> <tbody> <tr> <td id='cell_a1'>A</td> <td id='cell_b1' style='display:none'>B</td> </tr> <tr> <td id='cell_a2'>C</td> <td id='cell_b2' style='display:none'>D</td> </tr> </tbody> </table>` And I need to retrieve only the table's visible content using the .html() method, like this for the table above: <table> <thead> </thead> <tbody>

How to select an element based on the property of an object inside a data attribute?

微笑、不失礼 提交于 2021-02-08 05:22:22
问题 If my markup looks like this: <div data-test="{ "value" : "bar", "_id" : 1234, "name" : "john", "age" : 25 }">...</div> <div data-test="{ "value" : "foo", "_id" : 1235, "name" : "paul", "age" : 26 }">...</div> <div data-test="{ "value" : "drummer", "_id" : 1236, "name" : "ringo", "age" : 22 }">...</div> How would I select a particular element using JQuery if I only had the key 'bar' or 'foo'? I could pull out the whole object for each row and iterate through it looking for a match but I'd

When to use jQuery's .find() [duplicate]

核能气质少年 提交于 2021-02-07 02:59:32
问题 This question already has answers here : css selectors vs jquery traversal (2 answers) Closed 7 years ago . When would I use jQuery's .find()? For example, $('tr').find('.someClass'); is equivalent to $('tr .someClass') So, when would be a good example of when you would use .find() over a straight selector? Also, which is more performant? Is a selector quicker than .find() ? 回答1: The answer is whenever possible . It is always more performant than having children / multi-item / CSS / context

Jquery matching values

[亡魂溺海] 提交于 2021-02-05 10:59:06
问题 Hi I am trying to do an if statement to see if values have an exact match in an array. Then I want it the sibling element to show the html of what the exact match is. Can someone help please! I use TWIG for the HTML from Advanced Custom Fields Wordpress plugin. Image of all the locations that I want to say only once with the number of times they are mentioned. This is for a filter functionality. Eventually want to have a dropdown like https://codepen.io/luciopaiva/pen/YXYGYE?editors=101 with