jquery-selectors

Delete <dt> without <dd> with jquery

I have a definition list and I need to delete all the <dt> tags who doesn't have any <dd> In this particular case: Herramientas, Suplementos, Repuestos, Herramientas and Anti pinchaduras The list can vary wildly because it's stock dependent (any category <dt> can get empty) I tried this $('dt+dt').each(function() { $(this).remove(); ...

Replace Name Attribute with Variable - JQUERY

I am using a select element to change the search type on a media site (i.e. search by genre, search by artist). I have created the dropdown and can get the selected option via a variable but now I need to replace the name attribute on the input element with the variable/selected option. I have seen the below code to change the "value",...

How to select following input elements and how to get part of the ID using Jquery?

There are many input elements which IDs are question5,question6, question7 ,..., how to select these input elements using Jquery? I do not mean $('#question5'), I mean to select the group of them. Also How to get the the last number like 5,6,7,... using Jquery? ...

debug, Jquery function does not work

HTML code: The HTML code is dynamically created. <li> <div class="above">What do I like best?</div> <div class="below"> <label>Answer:(1 words)</label> <input id="question6" type="text" size="5"/> <label id="sign6"/> </div> </li> <li> <div class="above">What city do I like?</div> <div class="bel...

How can I find and hide the parents of elements with a given text content using jQuery?

In the example below, I'm trying to figure out how to hide the fieldset if the text within the tags = Groups <fieldset class=" collapsible"> <legend class="collapse-processed"><a href="#">Groups</a></legend> I tried this, but, it winds up hiding all the fieldsets, not just this one... $(this).find('legend').each( function() { if...

Dynamically added HTML not being recognized by Jquery

Read some other things on here re: this similar problem but am not sure how to apply this to my dilemma. I have a jquery function that replaces some HTML in a list.. For example, before the function runs: <ul id="mylist"> <li id="item1">blah blah blah</li> <li id="item2">blah blah blah</li> <li id="item3">blah blah blah</li> </ul> Th...

[jQuery]: append a selector

I'm trying to write a reusable function to retrieve all data in a table that is passed to it and store it in an array. I'm not sure how to pass the reference to the table. I could do something like... passTableRef($('#tableId th'),$('#tableId td')); but I would like to pass just the table reference in case I would like to elaborate ...

Like Facebook! Problem getting :contains value from textarea on keypress(e)? "DEMO"

I'm trying to fire an event on spacebar press if an url is found in the last word typed and kill that event if there is a result so if the user keeps typing... the function doesn't keep on sending requests to the server. I'm tired and hope this makes sense... Basically I'm trying to accomplish what facebook has when you submit a post a...

How to grab first dom element OR text string via jQuery?

Using the following sample markup: <ul> <li><div>Hello</div>World</li> <li>Hello World <ul> <li style="voice-family: dizzy">What a wonderful world</li> </ul> </li> <li><a href="hello.html">Hello World</a> <ul> <li>Goodbye world</li> </ul> </li> </ul> I'm try...

Problem with jQuery index()

There must be something simple I am missing. I'm trying to get the index of the element but keep getting -1. HTML: <div id="rating_boxes"> <img src="/img/ratingbox.gif" class="ratingbox" alt="Rate this Speech" /> <img src="/img/ratingbox.gif" class="ratingbox" alt="Rate this Speech" /> <img src="/img/ratingbox.gif" class="ratingbox" a...

jQuery(this).val() not returning the value of the selected option

I have the following script at the end of my page: <script type="text/javascript"> jQuery.noConflict(); jQuery(function() { jQuery('#optElem').change(function(){ jQuery.post('http://example.com', { 'id1': 1, id2 : jQuery(this).val() }, function(data){ jQuery('#abc').html(da...

jquery selector and Objects selection

typically when you refer to an object you would use a selector like this : $(this).jqueryfunction() if u would need an element within this object you would use : $('typicalselector',this).jqueryfunction() My question is how would I use jquery selector to select various objects something along the lines of : ($(this.fistobject) and...

How to find a div with part of a class name and get remaining part of that class name?

There are several divs on my page with classes my_widget-2, my_widget-8, etc. What javascript or jQuery code can I use to get the number "2" (ie. the number that appends the first matching widget)? Thanks in advance for your input. Note: If I were to write this question again, I would change the order of these class names and ask for ...

JQuery: Get tag content excluding nested tags

I've got some HTML like the following: <span id="A">Text I'm interested in <span id="B">Other crap I don't care about</span> </span> I'm looking to get the text content of span "A" excluding any nested tags (i.e. the content of span "B" in the above example). I'm trying to get the text content, not the HTML content. Also, in my part...

Jquery selector: How to: change the src attribute of an image tag on link hover

I need to change the src attribute of the image when the link is being hover on <div class="clear span-33 last" id="navigation"> <div class="hicon span-1"><a href="#" title="Homepage"><img src="../Assets/images/home.png" /></a></div> </div> Also change it to default when the link is not hovered on... ...

JQuery Selectors: How to select item with specific class *and* id

Hi all, I'm trying to select an HTML element on my page that has a specific class and ID. Here's the tag: <div class="statusLight" id="green"></div> I tried this with no luck: $statusLight = $('.statusLight#green'); I know that I could simply say $statusLight = $('#green'); But I was trying to find a way to select it based on ...

jquery img select

Hi, I have a h4 with an img in it like this. I bind a click function to the h4. This works well. But I'm not able to select the img in it. I want to select the img in order to replage the src attr with .attr("src").replace("up", "down"); . <h4 class="collapsable_head"> <img id="up_down" class="icon" src="/crm/img/modifier_down.gif" alt...

jQuery :nth-child() selector

Hi please look at the HTML below. I am trying to use jQuery to get every 3rd instance on the DIVs with class="box" contained within the DIV with class="entry" to have a no right hand margin: My HTML code: <div class="entry"> <div class="box"> SOME HTML.... </div><!-- end .box --> <div class="box"> SOME HTM...

jQuery selector question

I have encountered code that leverages jQuery, similar to the following. NAMESPACE = { propertyA : $("#selector-a"), propertyB : $("#selector-b") } $(NAMESPACE.propertyA).click(function(){ // ... }); This seems to work, even though the syntax for attaching the click handler should be. NAMESPACE.propertyA.click(function()...

Greater than selector in jquery?

Hi I have a table that has some rows in it. Here is an example of my table just with alot less table rows. <table> <tr> <td>bob</td> <td class="CheckThis">0 </td> </tr> <tr> <td>Jim</td> <td class="CheckThis">3</td> </tr> </table> Now I want to look at the second table cells and get rows back that have value greater...