jquery-selectors

using variable with jquery selector

我的未来我决定 提交于 2019-12-20 02:58:07
问题 I have following lines of code and I want to use visibleoffer variable as selector. How can I concatenate it? var visibleoffer = '.' + obj.parents('tbody').attr('providername') + ' .visible-offers'; //visibleoffer = .Txy .visible-offers $(obj).parents('.Provider').find(".Offers:not(.HideByProviderFilter,.HideByMainFilter,.HideByProviderFilter.HideByMainFilter,+ visibleoffer)").length; So it becomes: $(obj).parents('.Provider').find(".Offers:not(.HideByProviderFilter,.HideByMainFilter,

select elements using display:block

北慕城南 提交于 2019-12-20 02:57:06
问题 This is the html content from which I want to select all elements inside report having display block using jQuery $("#report:visible") does not work for me. <div id="report"> <div id="p1" style="display: block;"> <input id="pname1" type="checkbox" name="report1"> <input id="pname2" type="checkbox" name="report2"> </div> <div id="p2" style="display: none;"> <input id="pname1" type="checkbox" name="report1"> <input id="pname2" type="checkbox" name="report2"> </div> <div id="p3" style="display:

jQuery selector for all nodes in a given namespace

谁说胖子不能爱 提交于 2019-12-20 02:56:10
问题 I can easily select all nodes with a given name in a namespace: $("namespace\\:nodename") But I need more: I want to select all nodes in a given namespace. Ideally, this: $("namespace\\:*") But the wildcard is not accepted. TIA for your lights. 回答1: Since the all selector is not supported with a namespace, you can use it on its own (to match all the elements), then apply filter() to check the namespace yourself: $("*").filter(function() { return this.nodeName.toLowerCase().indexOf("namespace:

jQuery limit the number of elements shown to say like 5

蹲街弑〆低调 提交于 2019-12-20 01:43:13
问题 I got lets say this: <ol> <li>Content1</li> <li>Content2</li> <li>Content3</li> <li>Content4</li> <li>Content5</li> <li>Content6</li> <li>Content7</li> <li>Content8</li> <li>Content9</li> <li>Content10</li> <li>Content11</li> <li>Content12</li> <li>Content13</li> </ol> And the js something like this : $("li").hide() $("li:contains('Content')").show() Qusetion : Now How can i limit the number of shown elements to lets say around 5 ? 回答1: $("ol li:contains('Content')").slice(0, 5).show(); or: $

Alternative to .selector property now that it is removed in jQuery 1.9

北慕城南 提交于 2019-12-19 20:36:52
问题 As of jQuery 1.9 the .selector property of jQuery objects has been removed. (I'm a little confused as to why, exactly). I actually use it in a few unique scenarios, and I know that I could do other things to prevent this. Just wondering if anyone knows another way of grabbing the selector as of 1.9? $('#whatever').selector // (would of returned '#whatever') One example of where I need .selector is when I already have a group of checkboxes by name , and I want to see, within that group, which

Select sibling of parent on hover with jQuery

安稳与你 提交于 2019-12-19 18:10:49
问题 I'm trying to change the css of .target that is the sibling of the parent of .hover . Can't seem to get this code to work - I'm not sure if I need $(this) at the beginning of my function, or $('.target')... I think it might be .target because that is what I'm changing the css of with .css() . <script type="text/javascript"> $(document).ready(function() { $('.hover').hover( function(){ $(this).parent().siblings('.target').css('display', 'inline'); }, function(){ $(this).parent().siblings('

Logic AND for Jquery selector

半世苍凉 提交于 2019-12-19 17:13:02
问题 I want to set to checked a checkbox input by value AND name.. <input name="email" type="checkbox" value="1" tabindex="2"> How can I do that? I need that both conditions are done. This fails on && $("input[name=email] && [value='+i+']").attr('checked', true); This code is into a for iteration and "i" is taking a numeric value. Thanks in advance for your time and help... 回答1: Just use both selectors next to each other: $("input[name=email][value=" + i + "]").prop('checked', true); Any selectors

Does jQuery support CSS4 selectors?

烈酒焚心 提交于 2019-12-19 16:34:12
问题 Does jQuery or other JavaScript libraries support CSS4 selectors? Even browsers? How can I test them? 回答1: The only level 4 selectors that jQuery supports at the moment are :has() and the extended version of :not() — and that's only because the spec took inspiration from jQuery itself, as jQuery had already implemented them years before the spec had its First Public Working Draft published in 2011. I wouldn't expect jQuery to implement any of the other features until the spec has stabilized

How do I enable/disable options in Select Box using jquery

被刻印的时光 ゝ 提交于 2019-12-19 13:10:11
问题 I have a select box which contains the options and optgroup that are generated dynamically using php.Now when I select "ALL" all the other optgroup , options should be disabled and when I select any option other than "ALL" the "ALL" option should be disabled <select name="select1" id ="select1" onchange="handleSelect()"> <option value ="-1">ALL</option> <optgroup label="CARS"> <option value="ford">FORD</option> <option value="Nissan">Nissan</option> </optgroup> </select> <script> function

How do I enable/disable options in Select Box using jquery

人走茶凉 提交于 2019-12-19 13:08:24
问题 I have a select box which contains the options and optgroup that are generated dynamically using php.Now when I select "ALL" all the other optgroup , options should be disabled and when I select any option other than "ALL" the "ALL" option should be disabled <select name="select1" id ="select1" onchange="handleSelect()"> <option value ="-1">ALL</option> <optgroup label="CARS"> <option value="ford">FORD</option> <option value="Nissan">Nissan</option> </optgroup> </select> <script> function