JQuery :: Pass A Variable (which Is A Number) To The :gt(index) Pseudo-selector?

Mar 27, 2010

I am trying to pass a variable (which is a number) to the :gt(index) pseudo-selector.var thisParentIndex = $(this).parent().index(); //get the index of parent

console.log(thisParentIndex);
$(this).parent().parent().find('div.line:gt(' + thisParentIndex + ')').hide();

this does not appear to work..

View 3 Replies


ADVERTISEMENT

JQuery :: Cannot Pass A Variable To Selector?

Aug 5, 2010

I am trying to use (multiple) attribute selector and I have a string variable "txt" that I need to use in the attribute selector to select all <p> with all id's except for the id=txt

$(document).ready(function(){
$("p.par").click(function(){
txt = $(this).attr("id");

[code]....

View 2 Replies View Related

JQuery :: Cannot Pass A Selector Via A Variable?

May 14, 2009

im trying to figure out how to pass a target selector via a variablethe simple example below dosnt work, i was wondering why when i pass the varible target into the slector it does not work...

var target = "#1 .preview";
$(target).addClass("hidden");

View 1 Replies View Related

Pass Id Selector Content To A Variable?

Jul 16, 2011

Can I pass the content of an id selector to a variable?I am using a jQuery plugin which passes some data to an id selector ('#alt-text'). If I create a div tag with that id, the content for ('#alt-text') gets displayed in the div tag- everything fine. However, I need to split the selector (or parse the selector) to the assign different sections of the data to differnt div tags.

can't seem to get this started. If I try:
var xxx = $('#alt-text');
$('#otherDivTag').html(xxx);

it does not work. My desire is to do something like:

var xxx = $('#alt-text');
$('#otherDivTag').html(xxx).text().split(' ')[0];

View 3 Replies View Related

Return Index Of Array See If It Exists And What Index Number It Is At?

Jan 26, 2009

I have the below array called "results". When I loop through all document elements I would like to check "field_name" against the "results" array and see if it exists and what index number it is at??

// Split the comma delimited response into an array
results = result.split("~");
//Loop through array and populate fields[code].....

View 9 Replies View Related

Unknown Pseudo-class Or Pseudo-element 'visible'

Jan 28, 2011

having a warning "unknown pseudo-class or pseudo-element 'visible' "

View 2 Replies View Related

Get Index Of Selector?

Apr 2, 2011

Just 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?

View 10 Replies View Related

JQuery :: Pass Index Into Nth-child()

Apr 21, 2010

I'm trying to extend the functionality so that when a user clicks a button the formula will look up the values of the next column. These are then passed into the google charts api. So affectively they will see a new graph based on the next columns values. This is working fine

$('#WebPartWPQ11 .ms-vb2:nth-child(2)').each(function(i){
var points = $(this).text();
coord[i] = points;
});

So I thought if i declare a variable with the same default value, and pass that into the nth-child function it should return the values in the column. Once up and running by clicking the next button, the column would be incremented by 1, thus the formula would return the values in the next column

[Code]...

View 2 Replies View Related

JQuery :: Index Number In 'global' Context ?

Jun 21, 2010

HTML:

How to find index-number of 'a' - element.

$('table tr td a').index() - always returns 0, but I need an index-number of link not in 'td'-element but in 'table'-element.

View 2 Replies View Related

JQuery :: Pass A Selector Into A Function?

Apr 5, 2010

I am attempting to hack a jQuery extension that does an ajax style form submit. The final result is an image uploader that can run inline. The script is fairly simple - it creates an iframe with a new form, and copies over a form element (the file name), and submits the form. Plus error handling and the like.

The problem is that I need to use from within MVC, and so I need more form values, like the ID of the item I am working on. It would be easy to add another configuration setting for an additional form element to copy over, but I really want to have the ability to pass a jQuery selector in and use that to specify the form elements to copy. Is this possible?

View 3 Replies View Related

JQuery :: Show And Hide A DIV By Click On The Links (using Index Number)?

May 22, 2011

I searched before more and more but I can't find those things that exactly I want.

I'm on design a new website, you can see this page: [URL]...in this page I have 3 hidden DIV, and at top of content area I have 3 buttons (About, Karan Group, Contact), please click on those buttons and see action.

I'd write this motions by jquery but it's really really amateur! because I have to define all things like below codes (as working for output):

[Code]...

View 3 Replies View Related

JQuery :: Cycle Plugin - Return The Index Number Of The Currently Displayed Slide?

Nov 26, 2011

I'm currently usingMalsup's Cycle plugin. I am just wondering is it possible to have cycle plugin return the index number of the currently displayed slide? I want to change the content of the page when a specific slide is active. Don't know how to achieve that..

View 1 Replies View Related

Jquery :: Building Dynamic List Of Items - Adding Index Number?

Feb 17, 2009

I want to build a dynamic list of items with jquery but am unsure how to add an index number to each of the items i create so that i can reference them to edit or delete them for example. So far, I have the following which just creates the items and appends or prepends them to the element depending on whether one item exists already. I just need a way of adding an attribute so I can then reference the current item when clicked and remove it. What would be the simplest method to use?

//create list items
if ($('.mylistitem').length) {
$('.myList-box').prepend('<div class="mylistitem"><div class="mylistitem-image"><img width="30" height="40" src="[URL]"/></div><div class="mylistitem-title">' + title + '</div><div class="mylistitem-options"><a href="javascript:removetitle();">Delete From List</a></div>');
} else {
$('.myList-box').append('<div class="mylistitem"><div class="mylistitem-image"><img width="30" height="40" src="[URL]' + titleid + '"/></div><div class="mylistitem-title">' + title + '</div><div class="mylistitem-options"><a href="javascript:removetitle();">Delete From List</a></div>');
}

View 4 Replies View Related

JQuery :: $("selector" - Code) And .html() - Load Div In A Variable - Modify It In Another Variable And Then Change The Document Injecting The Contents

Dec 13, 2011

I want to load an html div in a variable, modify it in another variable; and then change the document injecting the contents.

1. I load the html to be changed in a variable (code)
2. I modify an attribute of <param> using attr() and I put the result in a var (newcode)
3. I change the html in the doc

I've used the debugger, and all steps give the expected results, except of newcode.html(), which is a null string. Why?

[Code]....

View 8 Replies View Related

JQuery :: Make Variable Out Of Index + 1?

Dec 6, 2011

Is it possible to make a variable out of index + 1 (or add a class) in the code below? I would like to put each in separate divs (dynamically) and add some css.$

(
document
)
.
ready

[Code]......

View 6 Replies View Related

JQuery :: Getting A Variable Out Of A Selector?

Jun 3, 2011

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?

View 4 Replies View Related

JQuery :: Possible To Use Variable In Selector?

Sep 25, 2010

Is it possible to use a variable in a selector? So instead of this:
$("#slider img").hide();

I want something like this
var wrapper = "#slider";
$(wrapper + " img").hide();

But this is just giving me this error:
uncaught exception: Syntax error, unrecognized expression: [object Object]

View 2 Replies View Related

JQuery :: Possible To Use A Variable In A Selector?

Apr 7, 2010

Is it possible for example to do:

var selec = 3
$(selec).etc...

and i wont it to have the same meaning as

$("#3").etc.... ?

View 1 Replies View Related

JQuery :: Adding Variable To Selector Id?

Dec 10, 2010

Basically I have a carousel, and when an item is hovered on, it's corresponding titles needs to show up below. I've managed to get a very inefficient version this working by repeating the function with the explicit id for the list item, but I'd like to get this working in a more automated fashion by assigning a variable that can be used with both the list item id and the paragraph id. I'm not sure if index() is the best way to go about this, or how to actually add the variable to the id's.

The HTML --
<div id="carousel_holder">
<ul id="carousel">

[code]....

View 1 Replies View Related

JQuery :: Use Variable In Selector Field?

May 26, 2010

I am new to Jquery.Is it possible to use variables instead of selectors? For exampleinsteadof #list2, #list3at the code below is it possible?

$(function(){
$("select").change(function() {
var selectedAttr = this.getAttribute("id")

[code]....

View 2 Replies View Related

JQuery :: Put Variable V1 Into Id Selector To Target DIV

Oct 22, 2011

I'm am trying to make a script that looks something like this:[code]This of course doesn't work. I don't no how to put the javascript variable v1 into the id selector to target the DIV with id="v1".I'm more a designer then a programmer.

View 5 Replies View Related

JQuery :: Using Variable Combination As Selector?

Oct 30, 2009

thisState="ALHouse";

I want to select all elements of class="placemark" and whose parent is thisState.

View 1 Replies View Related

JQuery :: Passing A Variable To A Selector?

Dec 3, 2010

function findDivs(id)
{
$('div[id~="' + id + ''"]').innerHTML = "insert this text into div's with id that contains the variable: id";
}

So the selector i am using isn't working. I'm pretty new to jQuery so the selector may be completely off.

View 1 Replies View Related

JQuery :: Syntax For Variable As Selector?

Mar 11, 2010

I have a number of input fields and pass their name and ID to this function, in order to clear the defaults and remove the initial class. :

[Code]...

View 2 Replies View Related

JQuery :: Using The Siblings Selector With A Variable?

Sep 14, 2011

I have a table where I hide a table row when the listen "item" is deleted. The item is deleted via jquery ajax. When the delete button is pressed, I call a plugin that creates a confirmation box. The plugin is passed a function to perform if 'Yes' is pressed.

[Code]...

The $(hideThis).hide(); line works. The tr is hidden from view. The next line is where I'm stuck. I know that how it is currently set up would never work, but looking at this will help you understand what I need to do. I want to edit the classes of all the tr tags that follow the one I just hid.

Here's the issue. I cannot just call the tr tag the same way I did to set the variable since I am no longer working in the same scope. And if I were to use this script the way it is written, the element it is looking for for the each statement is "[object] [object] ~ .lineItem".

View 5 Replies View Related

Way To Catch Index Number Of Form Element Array?

Sep 1, 2010

I want to get index number of form element array. where I want to put name in the front of code input box. Can any body tell me that how is possible. code...

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved