jquery-selectors

jquery: remove select options based on attribute array & other select box selection

空扰寡人 提交于 2019-12-22 14:05:06
问题 I'm trying to set up a set of select boxes to quickly filter fairly large datasets into usable chunks. And I'm very close, but receiving the exact opposite of the solution I want, whether or not I use .not() selector (or take it out), or set up the call using .attr= (or .attr!=). Here's a fiddle so you can see what's going on: http://jsfiddle.net/yD5cG/3/ (Ignore the fact that once you change the top-level selection, the bottom select box doesn't change. I won't need to worry about this). I

Fade out parent DIV - but not the children

核能气质少年 提交于 2019-12-22 12:30:17
问题 I have this HTML code : <div id="espacePub"> <div id="menu"> <ul> <li>Link 1</li> <li>Link 2</li> <li>Link 3</li> <li>Link 4</li> <li>Link 5</li> <li>Link 6</li> </ul> </div><!-- End Div menu --> </div><!-- End Div espacePub --> I want to select the div #espacePub but not the div #menu to fade out, change background and then fade in. With documentation found on http://api.jquery.com/not/, I tried this : var imgs = [ 'img/pub.jpg', 'img/pub2.jpg', 'img/pub3.jpg']; var cnt = imgs.length; $

Jquery Get Child DIV Within DIV

﹥>﹥吖頭↗ 提交于 2019-12-22 10:41:55
问题 I have the following HTML code within the body: <div id="hidden"> </div> <div id="mainContianer"> <div id="firstChildDiv"> </div> </div> I am using the following code to get the child $("div:first-child").attr('id') But this returns "hidden" when I want it to return firstChildDiv, I have tried things like... $("div[mainContainer ] div:first-child").attr('id') $("div[id=mainContainer ] :first-child").attr('id') $("#mainContainer :first-child").attr('id') I know its a simple thing to do, but

How do you select in-line text with Jquery?

巧了我就是萌 提交于 2019-12-22 10:33:46
问题 How can I select the text infront of the unordered list below? <li class="foo"> How can I remove this text? <ul class="bar"> <li><a href="#">Link</a></li> </ul> </li> I tried doing something like this: $('ul.bar').previousSibling().remove(); But I think that would only work with another element, and I'm not entirely sure how to go about selecting text that isn't contained inside tags. 回答1: Is the solution you're looking for. $('.foo').contents().filter(function(){ return (this.nodeType == 3);

Jquery: select all elements except one with specific child with specific attribute

梦想与她 提交于 2019-12-22 09:46:47
问题 Assuming I have something like this: <div class="testdiv"> <a href="/link1">link 1</a> </div> <div class="testdiv"> <a href="/link2">link 2</a> </div> <div class="testdiv"> <a href="/link3">link 3</a> </div> <div class="testdiv"> <a href="/link4">link 4</a> </div> Now I want select all <div> s of class testdiv except the div that has a child <a> with attribute href="/link3" , how to do that with jQuery? I know I can do this: $('div.testdiv') 回答1: With :not + :has it can be done easily with

Does jQuery have something like the :any or :matches pseudo-class?

半城伤御伤魂 提交于 2019-12-22 09:35:48
问题 I want to simplify my selector from: '#a #b a[href^=mailto], .c .d a[href^=mailto]' To: ':matches(#a #b, .c .d) a[href^=mailto]' Is this possible just using jQuery selectors? Or do I have to do this: $('#a #b, .c .d').find('a[href^=mailto]') Which isn't as flexible. 回答1: jQuery does not provide a selector equivalent of :any() / :matches() (of which :any() was the original form and it was first implemented internally in Gecko and WebKit). You will indeed have to break up your selector strings

Does jQuery have something like the :any or :matches pseudo-class?

南笙酒味 提交于 2019-12-22 09:32:05
问题 I want to simplify my selector from: '#a #b a[href^=mailto], .c .d a[href^=mailto]' To: ':matches(#a #b, .c .d) a[href^=mailto]' Is this possible just using jQuery selectors? Or do I have to do this: $('#a #b, .c .d').find('a[href^=mailto]') Which isn't as flexible. 回答1: jQuery does not provide a selector equivalent of :any() / :matches() (of which :any() was the original form and it was first implemented internally in Gecko and WebKit). You will indeed have to break up your selector strings

Select specific closest element

我与影子孤独终老i 提交于 2019-12-22 08:42:05
问题 I have the following html : <table id="objects"> <tr> <td> <input type="text" value="2" /> </td> <td> <a href="#" class="delete">link</a> </td> </tr> <tr> <td> <input type="text" value="4" /> </td> <td> <a href="#" class="delete">link</a> </td> </tr> </table> When I click anchor tag I'd like to select <input> closest to my link, and get it's value. How can I do this ? I was trying : $('.delete').click(function(e){ e.preventDefault(); var val = $(this).closest('input').attr('value'); alert(val

Sorting li elements by class with jQuery

时光怂恿深爱的人放手 提交于 2019-12-22 08:30:15
问题 I'd like to reorder li elements through an array with jQuery My list code looks like this: <html> <head> <script src="list.js" type="text/javascript" charset="utf-8"></script> <script src="jquery.js" type="text/javascript" charset="utf-8"></script> </head> <body> <div class="list"> <ul class="xyz"> <li class="element1">content for 1</li> <li class="element2">content for 2</li> <li class="element3">content for 3</li> </ul> </div> </body> </html> I now want to reorder the DOM elements through

Are there any good php libraries that can convert html/php documents into objects

こ雲淡風輕ζ 提交于 2019-12-22 08:05:14
问题 I see lots of php libraries that can parse html. A nice example is QueryPath which mimics the Jquery Api. However, I am looking to analyse phtml . So, not only would the library be good at analysing the DOM, but also be good at analysing the php processing instructions. e.g The Php Document Object Model or PDOM . A document like this: <?php require 'NameFinder.php'; $title = 'Wave Hello'; $name = getName(); ?><html> <head> <title><?php echo $title ?></title> </head> <body> <h1>Hello <?php