Skip to main content

All Questions

1 vote
0 answers
63 views

Best way to optimize a jQuery selector [duplicate]

I need select the tr of thead $("#table > thead > tr"); Is much the difference respect to this: $("#table").find("thead").find("tr"); Is there a way to optimize this jquery selector, what is ...
FQuijada's user avatar
  • 219
0 votes
1 answer
78 views

Will jQuery run faster if the HTML element name is added with the ID?

below is a snippet of code I use for added data to a table when a div is clicked on: $(document).on("click", "div#pos_product_id_<?php echo $row['id']; ?>", function() { $("table#...
eBookworm's user avatar
1 vote
2 answers
298 views

JQuery Performance: removing class

I have JS that runs to remove a class "modified" from all descendants of a form element. Which will perform better? $form.find('*').removeClass('modified'); or $form.find('.modified').removeClass('...
Kyle McClellan's user avatar
1 vote
1 answer
46 views

Peformance of universal selector, contradicting results?

According to the official website: The all, or universal, selector is extremely slow, except when used by itself. So, I think this means that $("#section").find("*") should be faster than $("#...
SanJeet Singh's user avatar
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
0 votes
1 answer
313 views

What is faster/more efficient - $(".selector").height() vs $(".selector").eq(0).height()

I have 20 x element.selector with same (100px) height and I need to get their height (100px, not 2000px). What is faster/more efficient to do? $(".selector").height() or $(".selector").eq(0)....
psyduck.the.apex.predator's user avatar
3 votes
1 answer
2k views

How to extend a jQuery selector that is stored in a variable?

I have a jQuery selector stored in a variable, like so: var myVariable = $( ".js-selector" ); I'm wondering if and how I can use this variable to select children of this element, instead of writing: ...
Johan Dahl's user avatar
  • 1,732
1 vote
1 answer
275 views

jquery class-selector vs qualified class-selector

I am currently writing my bachelorthesis about webperformance and just came across some results I didn't expect. As Paul Irish or jquery itself recommend it's always best to descend from an id. http:/...
haeki's user avatar
  • 152
0 votes
1 answer
313 views

jQuery: Is using children() more efficient than using child selector

I often need to setup jQuery events on li tags that don't have a class or ID associated with them like in this example: <div id="menu"> <ul id="nav"> <li>Nav Item ...
mpls423's user avatar
  • 63
2 votes
1 answer
660 views

Jquery - Fastest way to get children elements [closed]

my work requires me to work with jquery a lot. Since i am always trying to find a better way to do things, i would like to improve performance on javascript level of page. so i was wondering what is ...
em2's user avatar
  • 93
0 votes
1 answer
23 views

jQuery selector performance options

I working on this code currently var cctypeid = $(this).attr("id"); var data = $.parseJSON($("#"+cctypeid+"-id").val()); $.each(data, function (index, item) { }); Inside the .each() I need ...
dbinott's user avatar
  • 911
0 votes
1 answer
120 views

Operations degraded by DOM complexity?

I stumbled across this jsperf. It tests the relative performance of editing the html of an element accessed by id only or by id via a cached selector. The element edited is 17 levels deep. jsperf ...
user avatar
0 votes
2 answers
47 views

Jquery using multiple selectors to show all at a time

I have jquery code to show 3 items at a time $('.a').show(); $('.b').show(); $('.c').show(); I can also achieve the same with $('.a, .b, .c').show(); What is main difference between both codes? ...
Kurkula's user avatar
  • 6,594
8 votes
5 answers
360 views

Best method to select an object from another unknown jQuery object

Lets say I have a jQuery object/collection stored in a variable named obj, which should contain a DOM element with an id named target. I don't know in advance if target will be a child in obj, i.e.: ...
BlueYoshi's user avatar
  • 1,574
0 votes
5 answers
86 views

Is there a direct way (at the lower level) to do $('#id')?

I mostly call jQuery elements by the id of the DOM object using the $('#id') syntax. I think that this goes through the selector algorithm, and spends some time on that process. I was wondering if ...
sawa's user avatar
  • 167k

15 30 50 per page
1
2 3 4 5
7