Skip to main content

All Questions

0 votes
1 answer
35 views

Making a variable element from existing element / querySelector doesn't accept Variables

Im trying to select a child div from an array with the variable x This is only a sketch to illustrate what I'm trying to do: var x= 0; trackN = document.querySelector( .track :nth-child(x)) But ...
Dr_ Buhu's user avatar
-3 votes
1 answer
97 views

How to select an element with attribute based on variable selector which is defined earlier?

var $label = $('label'); //How can I select a `label` using attribute selector, something like below. $label['data-id=1'].text('some value'); //There is no such a syntax, I am just trying to explain ...
phpguest's user avatar
  • 794
1 vote
1 answer
36 views

Apending variable in Jquery selector

I have this selector self = $('.trim .person:nth-child('+index+')'); self.append('<img src="'+element.profilePic+'" class="profilePic" />'); I then want to use this select a class within $(...
LeBlaireau's user avatar
  • 17.4k
2 votes
4 answers
7k views

How can i use a variable in a Jquery selector? [duplicate]

How can I make this work? variable scope contains either Menu or Content. So i need it to find a input with the id Scope_Menu or Scope_Content depending on the variable scope. var scope = $(this)....
Mike Lammers's user avatar
2 votes
1 answer
63 views

using variable with jquery selector

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'; /...
Huma Ali's user avatar
  • 1,779
2 votes
1 answer
218 views

How to address Jquery Selector with Variable

I have a div with a class of boxcatID that has html changed from a jquery script. The problem is that my particular page has many of these divs, so my script of course affects all of them when it ...
FunnyGirl's user avatar
1 vote
3 answers
700 views

jquery combining multiple variables (elements set as vars)

I am trying to learn a bit of Javascript/JQuery for school and got stuck on something I don't quite understand. Everything in my function "works" as I wanted it to, but it feels odd that I have to ...
IvanG's user avatar
  • 13
1 vote
1 answer
55 views

Store $('body, html') selection as jQuery

I'm optimizing the JS code, and stumbled over this question: At various places in the scripts there are jQuery selectors which select 'body, html', mostly to change/check-for a class. Now I was ...
jacksbox's user avatar
  • 921
1 vote
2 answers
540 views

The variable in element nth-child using jquery

I'm stuck and I can't overflow counting children using variable and jquery. What I do: <ul> <li>First</li> <li>Second</li> <li>Third</li> </ul&...
Lech's user avatar
  • 61
0 votes
2 answers
50 views

How can multiple variables be used to create multiple jquery selectors?

When I convert multiple variables into multiple selectors the below code fails to execute. DEMO HERE $('.Btn').on('click', function () { var outer = $(this).data('test'); var inner = $(outer)....
DreamTeK's user avatar
  • 33.6k
1 vote
2 answers
103 views

Correct way to add variable and selectors to a not function - jquery

I have checked a few answers on SO and I think my syntax is correct, but something is not working correctly. I am trying to create an array of jquery selectors mixed with variables and store them in ...
lharby's user avatar
  • 3,204
0 votes
1 answer
48 views

How do I select an element within a variable to trigger play <video>

I'm using the RoyalSlider plugin. I'm getting the DOM content of the current slide using the following code. jQuery(document).ready(function($) { var sliderS = $('.royalSlider').data('royalSlider'...
user avatar
1 vote
1 answer
421 views

Targeting divs inside a variable ID found using a class

I need to add various IDs, an href, and data-parent attribute to a few elements inside div 'myId' - of which I would like to return the ID of the div with the given class : ".template-none .section-...
user4329628's user avatar
1 vote
1 answer
54 views

jquery variable: selection order doesn't update

It's considered best practise, according to Learning jQuery, to save common selections using variables, as it can save time and resources and help avoid errors through repetition. A good thing when ...
shley's user avatar
  • 203
0 votes
2 answers
41 views

Using variables in place of calling jQuery selectors

var container = $("#container"); var row = $(".row"); container.append("<button>CLEAR SCREEN</button>"); for (i = 1; i <= x; i++) { container.append("<div class='row " + i + "'>&...
wannabeprogrammer's user avatar

15 30 50 per page
1
2 3 4 5