Nth-child Selector - What 'n' Stands For
Oct 13, 2009Don't understand is what 'n' stands for. for example in this code:
And then what does the +1 do?
Don't understand is what 'n' stands for. for example in this code:
And then what does the +1 do?
If I use an child selector like in [url] how can I prevent it from being applied to all tables?I need to select an child from only one table.
View 2 Replies View Relatedaccording to the docs this 'should' work in all IE versions except 6.Examples :
$("#gallery > img").css();
$("#gallery").children("img").css()
Even tried $("#gallery").find("img").css() None of those methods will work in all versions of IE(even 8). Works just fine in FF, Safari, etc...Is there a work around or another method of selecting the children of a selector in IE? I would really like to not have to add extra classes to those images just to select them.
I was wondering if there is a "selector construct" that matches an element having more than one child. So I'm looking for a solution that doesn't need
an if statement such as;
if($('ul').children().size()>1)
{
//do this
}
[Code]....
But I'm looking for a selector that already looks for these conditions. Kind of like how :has() works but then a check for more than one child.
What is the syntax for accessing the children of a class, where the class is a variable?The html structure is multiple divs like this:
<div class="class1 class2 class3">
<p class="x"> lorem</p>
<p class="y"> ipsum</p>
<p class="z"> yadda</p>
</div>
(There's a structural reason for accessing the child <p> tags, rather than just the parent <div>s. Some <p> tags in some<div>swill have previously had a style change applied: if the changes are now applied only to the parents, some children won't changeā¦ at least not till they're hidden).Anyway: this code doesn't work, doesn't generate a FF error message, and doesn't stop subsequent chained functions from operating. So it can't be far off; and the syntax$(cl + ' > p') works ok in another function.
I've been fiddling around with a bit of javascript in a chrome extension - something to alter the Google buzz webpage.I'm trying to find each individual post basically and have the following:
var entry =$('.X0POSb'); //This main block contains the bulk of Google buzz content
console.log(entry);
var items = entry.find('.G3.G2');
[code]...
I want to do something like this
<div>
<p>
<p class="active">
[code]....
I'm trying to find an example of a country selector (which also provides a state selector if USA is chosen) then you cvan select the city, any samples out there?
View 2 Replies View Related<div class="userbox posts" id="pst146996">
<div class="imgholder">
<img alt="Chris Hardin" src="http://codebix.com/bp/1633.png">
<div style="margin-left: 20px;" class="commentbox">
[code]....
i want already select .postlike in $(this) now i want to select the tagh1 who is in .commentboxelements.i want to change the h1's inside text 1 to 2 so i write the code
$(this).closest('.posts').children('.commentboxelements center h1').html('1');
i try this but it's not worked anyway how i can do this.
Are there any difference between class selector and ID selector
View 2 Replies View Relatedso i wrote this slider with some help from an admin, everything works as I would like it to but I'm trying to make it a plugin so i need to tighten up a certain part of the code:
(function( $ ){
$.fn.jmSlider = function() {
// get total width of all li elements in the slider
var wrapWidth = 0;
[code]....
what i would like to do is instead of using "li:first" and "li:last", i would like to use first-child and last-child so the element doesn't need to be a li, in can be anything that is the direct child of the parent container.
I have created parent child checkboxes. When one child is selected, then parent of that child, other child of same name and parent of that same name's child will be selected... Now I want if I unchecked any child, then only same name of child and parents should be unchecked or if I unchecked Parent Child, then same name of parent and child will be unchecked.
[Code]...
I have a difficult work around Jquery. I want to remove all li items from the ul except first li and last three li how to remove the li elements from these list.
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
[Code].....
I have a parent window that pushes a new window object onto an Array
with the following code :
OpenChild()
{
//totalNumWindowsCreated is global
totalNumWindowsCreated = totalNumWindowsCreated + 1;
childWnds.push(window.open(link, "child" +
totalNumWindowsCreated,"dependent"));
..
..
..
}
This pops up a new window with every call. In the child window I call
a parent function onbeforeunload, appClose() :
function appClose(){
if (window.opener && !window.opener.closed){
window.opener.CloseChild(getQueryString("application"));
}}
This is in my frameset tag of the child code :
<frameset ... onbeforeUnload='appClose()'>
The window.opener.CloseChild() function is called perfectly when I have
one child window open, but as soon as I create another child window
both of the open child windows don't ever call it. They do both go
into the onbeforeunload appClose() function, but do not call the
window.opener.CloseChild() function inside of this routine.
Anyone have any ideas why when I have two child windows open I can't
access the window.opener functions?
I have tried taking each new window out of the array and used the
following code in CloseChild() :
CloseChild()
{
//win and totalNumWindowsCreated are both global
totalNumWindowsCreated = totalNumWindowsCreated + 1;
var win = window.open(link, "child" +
totalNumWindowsCreated,"dependent");
..
..
..
}
I'm trying to write a piece of javascript to select a particular css file based on the browsers screen resolution. At the moment I've got this:
var ScrnSize;
ScrnSize = screen.width + "x" + screen.height;
switch(ScrnSize) {
case "800x600":
document.write('<link rel="stylesheet" type="text/css" href="style/lowres.css" />');
default:
document.write('<link rel="stylesheet" type="text/css" href="style/hires.css" />');
}
But it always seems to go to the default value no matter what. I'm a newb at javascript,
I'm trying to create a drop down menu which has several levels. When a level is clicked on, other expanded categories in that level should minimize simultaneously. The trouble I'm having is using a combination of selectors to say 'all divs which match this pattern but not this one'. I've had a look through the selectors API pages
View 1 Replies View RelatedJust started to dabble with jQuery I can get the id for a clicked element, but how can I retrieve its index number within the class?
Code:
$(".heading").click(function () {
$("#containContent").slideToggle(100);
//window.alert($("#containContent .content").length);
window.alert(this.id);
});
Hopefully I can do this from the 'this' reference without having to backtrack through the id?
I have a page using Moo Tools with 4 images. What I would like to do is to pass a boolean value to an array that exists outside of the image, but then I need to test to see if all elements outside the array are true. If so then I want to alert the user.
View 1 Replies View Relatedi use it in a CMS. In my content page, when I insert a floating element, I use it to set the margin around element according to left or right float in this way:
$('#content img[style*="float:left"]).css({
'clear' : 'left',
'margin': '0px 20px 10px 0px'
});
in chrome, mozilla and not-IE browser the selector with (: and/or ;) works but in IE doesn't work. Is there a solution?
I have a problem that I couldn't solve myself. I have 2 forms. name="form1" and name="form2" In each form, there's the same class names for rows. <tr class="draggable">
What I need to do, is to take the last draggable row in a certain form. $( tr_object + " tr.draggable:last" ) <- returns the last tr with class draggable in whole document. How do I limit It's view/search scope to one of the forms only?
var string = $('#newItemInput2').val(); // gives me "twats"
But when I try and embed it within an object it doesn't work:
Can a jquery selector not be used as the member of an object?
this code works for me , but there is something wrong , every time the function loads (every 2.5 seconds )the html is loaded in row [0] cell[0] , and they are stacked above each other . what may be wrong there ?
code :
var searchtable=document.getElementById("searchtable")
var resultscount=0
[code]....
I am using the contains selector for one element because I do not know the full ID. Since I only need the first element it finds should I be adding something to improve performance?
View 8 Replies View RelatedOn our current project we had an very unexpierenced coworker which wroted an "a" tag as an jquery selector. to better understand what he did see the following working sample:
<html>
<head>
<script type="text/javascript" src="
http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
</head>
[Code]...
This works in Firefox but not in IE (of course not Yeah we know its wrong, but we dont find a reason for its working in firefox ! can someone explain why this can even work ?
That's my code:
var main = $("#content_value td:contains('Saque')").next();
alert($("img[title='Ferro']", main).text());
I'm trying to get the img element from the main selector, but it's not working..
[Code]...
The following code works:
$('#prov_1 .toggleEdit').click(function () {
$('#prov_1 .editable').toggle();
});
When I click on the "toggleEdit" button under #prov_1, the .editable elements in #prov_1 appear/disappear.
Now I want to do this for all prov_N.
$('#prov_' + pid + ' .toggleEdit').click(function () {
$('#prov_' + pid + ' .editable').toggle();
});
does not work. How do I extract or define N, the pid number?