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?
I need to get the attribute id of the current element which comes from a selector. As I found out with the help of this forum I need to use $(this).attr("id"). Unfortunately this just returns "undefinied" for me. Does anybody have an idea why this doesn't work?
is there any way one can test if an element matches a jQuery selector? I'm not trying to locate elements, just test for match.
More specifically, when using event delegation and a common callback function for multiple events, is there a way to check the event's currentTarget against a selector?
In the following example, how can I check if the currentTarget is the LI node with class "item2"?
i have jquery code which highlights <p> elements with specific class. everything works ok but if i update elemet with content including tag <p>, highlighting doesnt work.
I'm working with jQuery on a form where each input element is contained in an <li> element.
Some fields are read-only, identified by a class ".readonly", and I'd like to bind a jQuery function to these fields' "focus" event, to send the focus to the next input whose class is not read-only.
But, because of the containing <li> elements, I don't think .next('input') will work, since the <input> tags aren't siblings.
Is there a simple selector that will do the job without having to climb up and down the DOM via parents and children? To me that feels unsatisfactory and brittle, because should the designer decide to change the layout (lists within lists, <div>'s within <li>'s), my DOM-climbing code might break.
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.
I'm trying to create an accordion (jquery ui) that shows information about its items when clicked. The information for these items is grabbed from 4 locations:- one to get the item's basic structure info one to populate an 'interoperability' info box where the 'service' and 'about' properties match a box like the 'interoperability' box, but for 'similarity' info a file with user-created 'annotation' information about sub-items that could be shown.
I have a single web page that is broken into content sections that are all assigned element id's (home, about, services, and contact) and have a fixed navigation bar that points to anchors associated with each element id / page section. Since the navigation bar is fixed, it comes along with us as we scroll through the page. I've got a jQuery smooth scrolling effect that makes a nice transition between sections of the page when you click on one of the navigation links. Between the sections I have an image that looks cool as the page scrolls past between sections.
Problem:Since the page is kind of long, I would like to use the jQuery .hide method to remove page sections that lie between the current section of the page that is being viewed and the section targeted by the navigation link. At the same time, the .show method will be used to ensure the target section of the page is visible. Therefore, I need to include an exception to the list of elements that I am hiding - the element that I am currently viewing (and is consequently being displayed as the current url in the browser due to the anchor tags).ExampleFor instance, say you're viewing the "about" section of the page and you click the navigation link to the "contact" section. The "contact" link in the navigation bar is assigned the id="nav_contact." When you click the "contact" button, I've made the following jQuery happen:
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?
i have a menu generated by a list with nested lists. i want the parent link to stay highlighted when the mouse hovers over the sub menus. because those sub menus are also generated by jquery (qtip), CSS alone won't do it (triedul.topnav li:hover a {background-color: #F00;}).is there a way to do this using jquery?
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
i 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:
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?
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
On 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:
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 ?
$('#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?