What's the easiest way to find Dom elements with a css selector, without using a library?
function select( selector ) {
return [ /* some magic here please :) */ ]
};
select('body')[0] // body;
select('.foo' ) // [div,td,div,a]
select('a[rel=ajax]') // [a,a,a,a]
This question is purely academical. I'm interested in learning how thi...
What is returned if $('#id') doesn't match anything? I figured it would be null or false or something similar so I tried checking like so:
var item = $('#item');
if (!item){
...
}
But that didn't work.
...
Given the following HTML:
<ul>
<li><div>Some content</div></li>
<li><div>some more content</div></li>
<li><div>final content</div></li>
</ul>
I would like to apply a top border around each div. On the last div I would like to put a bottom border. I am targeting IE7/8. I have the top border working fine, I need help getting th...
I would like to write a greasemonkey script that given an xpath returns all of the output of that xpath executed on the current page in a .txt file with one result per row.
How do I do this?
EDIT: Its ok if the output is not written to a file. I just want to have it displayed.
...
I'm trying to style table cells within a table based upon whether or not the contain the character | in the url or not (don't ask, dealing with SharePoint).
Sample HTML;
<table>
<tr>
<td class="ms-cal-workitem">
<table>
<tr>
<td class="ms-cal-monthitem">
<a href="http://localhost:4657/1">Event 1</a>
</td>
</tr>
</table>
</td>
</tr>
...
So Basically I am trying to keep the top level categories image of a down arrow turned on while hovering over the submenu's elements. I want to do this through jQuery on a hover function however I cannot for the life of me get a selector to target the sub menu items.
Here is the code I am trying to run:
$(document).ready(function() {
...
What is the selector syntax to select a tag within an id via the class name? For example, what do I need to select below in order to make the inner "li" turn red?
<html>
<head>
<style type="text/css">
#navigation li
{
color: green;
}
#navigation li .navigationLevel2
{
color: red;
}
</s...
This is related to my previous question about selecting visible elements. Now, here's the twist: Let's say I want to select the odd children only from the set of visible children of an element. What would be the best way to do this?
Edit: here is an example of my input and expected output.
<!-- A list with some visible and invisible ch...
i have a table
<table>
<tr>
<td class="myA">Data...1a</td>
<td class="myA">Data...2a</td>
<td class="myA">Data...3a</td>
</tr>
<tr>
<td class="myB">Data...1b</td>
<td class="myB">Data...2b</td>
<td class="myB">Data...3b</td>
</tr>
<tr>
<td class="myC">Data...1c</td>
<td class="myC">Data...2c</td>
<td class="my...
i am abit confused between these 2 selectors
div p
selects all p within a div whether or not its an immediate decedent? so if the p is inside another div it will still be selected?
then child selectors
div > p
whats the difference? does a child mean immediate child?
eg.
<div><p>
vs
<div><div><p>
both will be selected?
...
At the moment I am just resetting the styles I need at the top of my style-sheet, like:
html, body, div, fieldset, form, h1, h2, h3, h4, p, ul, li {
margin: 0;
padding: 0;
}
However, I have seen a lot of times that people use:
* {
margin: 0;
padding: 0;
}
That does seem to make things easier, but somewhere else (don...
What's the difference between the space and > selectors? And possibly related, how can I look for something that's the direct child of something else, and not lower down the descendant line?
...
Hello,
I have a bunch of divs like this:
<div class="bear"></div>
<div class="dog"></div>
How do I get a nodelist that includes all divs with class of bear and dog? I tried:
Y.get(".bear .dog").each(function() {
});
But it returns null. Anyone have any suggestions? Thanks!
...
I have some legacy CSS I wanted to clean up. Person who wrote it is not available for consultation. The following rule does not validate (CSS 2.1):
html[lang=en] q: before, : lang(en) q: before {
content: "“";
}
Would it be safe to assume that the author mean the following (this validates):
html[lang=en] q:before, q:lang(en):befo...
Definitions lists are a great way to mark up information where some key word is associated with one or more values.
Since there is the semantic association of a dt with one or more dd elements, is there a way to use CSS to select these associated items.
Consider the following html:
<dl>
<dt>Foo</dt><dd>foo</dd>
<dt>Bar</dt><dd>bar...
My form inputs display properly if pixel padding is used, but using a percentage padding for left and right breaks it. I can't figure out why. Demo @ http://stonewatercove.com/test.html
It works in Safari, broken in Firefox 3.5.3 OSX.
The problem is that when I use a percentage padding, the padding all breaks (hence why the input value...
Hey,
I am looking for a CSS selector for the following table:
Peter | male | 34
Susanne | female | 12
Is there any selector to match all TDs containing "male" ?
...
I'm working on a CSS file and find the need to style text input boxes, however, I'm running into problems. I need a simple declaration that matches all these elements:
<input />
<input type='text' />
<input type='password' />
... but doesn't match these ones:
<input type='submit' />
<input type='button' />
<input type='image' />
<inp...
I know there can be only one unique ID attribute per document.
To be sure, I need real doc link where this is written.
...
How can I count the number of elements that match my CSS selector??
I am trying to use SeleniumRC to test my GWT App and am trying to match elements using CSS selectors.
I want to count the number of enabled Buttons in the following HTML.
A button is enabled if it is under a td with class="x-panel-btn-td "
and disabled if it is unde...