I'm trying to figure out which selector is faster (assuming that the class 'foo' only appears on input tags)...
$('.foo'); or $('input.foo');
From what I've seen online, it seems that people recommend $('input.foo'), but in some limited testing it appears that $('.foo') is much faster in both FF and Chrome. In IE, both methods seem to produce similar results. Here is a fiddle with a simple example...
Have browsers started implementing native ways to find all elements with a given class name? Would that explain why $('.foo') seems to be faster?
[URL] The above webpage lists the selector .class.class without an example. I can't find this usage in jQuery document either. I made the following example, but it doesn't work. Could anybody let me know who to use the .class.class selector?
I am trying to make a sliding panel if you click a button, the only problem is that there are more of this panels on the page. I can make the first one open, but I cant make the one opening wich has the id=id.
I am unfortunately having some problems with JQuery of late. I am working on a project in which I need to have an AJAX application working in all major browsers, including IE6 and IE7. I have created a click event for a button of the class "update" and "delete" in which an ajax request will be sent to the server. Unfortunately in IE6 (and only IE6) the event will not fire. After much experimentation I realized that it was the class selector.
Here are some code tests I have been doing to get a click event to fire:
Do you have any ideas as to why none of these work?
Version 1.2.6 used to add style="display: none;" when hiding, and would remove it when showing. Version 1.3.2 adds toggles between style="display: none;" and style="display: table-cell;". I don't think that matters really, what does matter however is that if I alert jQuery('.more').length I get 1 not 4.
I am a newbie here and had a strange problem, maybe someone can explain it: I have a function that changes it's element class on click. I Also use the class as selector for that function. So, when clicked, it should not be clickable again. But it does, like if, even after removed, it's class would still remain in the memory of DOM, or something.
(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.
1. I want to have 2 things on my page: an unordered list of links at left, and a grid of images at right. Each item in the list is represented by an image in the grid. This is how it should work: when you mouse over an image, the text link at left changes color. So, I hardly know any jQuery, but I suspect that you need to dynamically insert a css class selector into the <li> for that list item. How in the world do I do this?
2. I am using this plugin: jQuery cycle lite. Is there a way to make the images appear in random order, rather than in the same, fixed order?
<span id="more"> Did you know? <span>The milky way is round.</span> </span> Using $("#more span").css("border", "1px solid black");
will place a black border around "The milky way is round." If I change the <span> tags in the HTML to <div> tags and issue $("#more div").css("border", "1px solid black"); The same will happen. "The milky way is round" will be framed. However, if I change the <span> tags to <p> tags, as in
Form that code I would expect the class of 'testclass' to be applied to the button after the link is clicked, but It doesn't seem to work. This is a somewhat contrived example. In my real application I have a form with several collapsable/expandable sections. If the fields in those form sections have values when the page loads, the section needs to be expanded, and the expand/collapse button needs to have a class of 'expaned' applied to it, if not it needs to be hidden. I can check the form fields and show the div if needed without any problem, but I can't seem to figure out how to work out the selector so I can add the class to the button.