JQuery :: Selector Only Selects One (last) Of Matched Classes
Aug 25, 2010
I have code to add a row dynamically to a form in my page when an element with class 'addRow' is clicked. The tables (2 tables in one page) that I want to add the row to have class 'tableAddRow'. The tables are contained in a form. But for some strange reason the code only adds to the last matched table in the page. I tried using the $.each selector but nothing works.
Here is the code:
$(document).ready(function(){
$(".addRow").click(function(){
$(".tableAddRow tr:last").clone().insertAfter(".tableAddRow tr:last");
$(".tableAddRow tr:last input").val("");
});
});
View 5 Replies
ADVERTISEMENT
Apr 13, 2011
where can i find an example of how jQuery selects objects when using an id selector? i'm asking because i've been using a cross browser snippet to select objects and i was wondering if it's the right move to move from the snippet to jQuery. the snippet checks to see for availabe methods and depending on the one that works, it knows which browser the user is using and selects the object using that method. i also know jQuery is cross browser, so it's kinda implied, just wanna make sure.
View 1 Replies
View Related
Apr 24, 2009
So I understand you can do:
$(".className").xxx.
Is there an easy way with jquery to have it match 2 classes. So maybe I only want the action to take place it the element has class1 and class2.
$(".class1" , ".class2").xxx
The above is close to what I would like, but thats if any of the 2 classes match, go. I need it to be both. I can probably do this with some basic javascript logic.. just figure there may be a function for this already.
View 4 Replies
View Related
Sep 19, 2009
In order to allow users to filter content, I've created a small checkbox list. To each checkbox is attached an ID, and too some divs on the page are attached these id's too (in the class attr that is); one div can be attached to multiple id's, and so have multiple classes.
In order to show or hide my div's I wrote :
function couponsVisibles(){
$('.checkInteret').each(function(){
var coche = $(this).attr("checked");
if (coche) {
var idCoupons = $(this).attr("id");
$(".zoneCoupon , div[class='" +idCoupons+ "']").each(function(){
$(this).fadeIn();
});
}});
}
$(".checkInteret").click(function(){
var coche = $(this).attr("checked");
if (!coche) {
var idCoupons = $(this).attr("id");
$(".zoneCoupon , div[class='" +idCoupons+ "']").each(function(){
$(this).fadeOut();
});
}couponsVisibles();
});
It looks like my selector "$(".zoneCoupon , div[class='" +idCoupons+"']")" doesn't work, but I can't figure out why. I've started using the [attribute*=value] selector, but this selector doesn't seem to make a difference beetween class='8 10' and class='8 1'...
View 1 Replies
View Related
Feb 22, 2010
I'm a starter in using jQuery and I decided to work my way through the 'Learning JQuery' book from packt.Somewhere in Chapter 5 they use the clone() function with the false attribute. The JQuery version used in the book is 1.1.3a. With the clone(false) method the writer can clone only the matched element and not the descendants. And that works in 1.1.3a.I know that this is no longer the case in JQuery 1.4. Boolean is only for Event Handlers.But what is the new equivalent of this method? In other words. How can I clone an element with only the matched element and not it's descendants?
View 2 Replies
View Related
Mar 24, 2011
I know you can use :even or :odd to get the even or odd indexes from a set, or :lt/:gt to filter down the matched set before/beyond the specified index. But what if I want to select every 5th element? And I know it's not nth-child, because that selects everything that is the nth-child of it's parent and not if it is one of the nth elements in the matched set. Is the only way to use .each(function (index) {...}); and then check if the index makes that element one of the nth items?
View 2 Replies
View Related
Oct 15, 2010
I have spent the last week trying to figure out how to do the following: User types some text in a text box. The autocomplete queries a php script that returns JSON of matched values. I have got thedrop down list to show these values but I cannot for the life of me get the matched characters to turn bold. For example, if the user types in "rav" and my list contains:
RAVEN
RAVE
RAVEL
then I want it to appear as
RAVEN
RAVE
RAVEL
My current JS code is as follows (along with HTML):
$(function() {
$( "#query" ).autocomplete({
source: "get_json.php",
[code].....
View 6 Replies
View Related
Aug 19, 2010
I am new to jQuery and I am having trouble with the syntax, selectors and refining when trying to create functions. What I am trying to achieve: I have a gallery consisting of a ul with images placed in vertically stacked list items. The ul is in a fixed size wrapper with overflow:hidden so only the first list item displays. The user clicks a button and the first li is hidden using hide(400). This makes the other list items flow up and reveals the second list item within the wrapper window.
When the last list item is visible, the click will show(400) all of the list items again, causing them to flow back into order and only the first item will be showing again. Further clicks will repeat this process from the beginning. I know what I would like to do in terms of code, but I am having trouble with the correct syntax, selectors and refining. I have included the html and description version of the code I was hoping to create. I know the code could be much more efficient by placing functions into variables and testing for true false, but I would like to see the steps with my longer code description for learning purposes. Perhaps afterwards someone can blast it off in two lines.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]">
<html xmlns="[URL]">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>list hiding test</title>
<style>
.listWrapper {
height:25px;
width:380px;
background-color:#d6d6d6; .....
View 2 Replies
View Related
Jul 16, 2009
I'm having an annoying issue with addClass(). I'm trying to find all divs with id name '#moldura_slides' and add the class '.horizontal' to each one of them. The problem is that only the first div matched gets the class. The others are just ignored and don't get it.
$(document).ready(function(){
$("#moldura_slides").addClass("horizontal");
});
This is the page: [URL]
View 3 Replies
View Related
Dec 9, 2010
Code HTML4Strict:
<div id="veg">
<a title="Tree" href="x.html"><a>
<a title="Leaf" href="y.html"><a>
</div>
[Code].....
Each anchor is unique, but the title attribute may match the exact title of one or more images. Where a match is found, either once or more, the title text is copied - once - into the anchor element.
How to do with jQuery?
View 4 Replies
View Related
Apr 15, 2010
I tried to use delegate, but it is bounded with events. I don't really want to execute a function on a standard event. But I would need to change the elements that match a selector, when they appear in dom. Is possible to "unhook" delegate from events?like for all existing and new elements with class ".red" to add to the "data" a new key "initiated:true".
View 2 Replies
View Related
Jun 1, 2010
consider the following code;
$("#content").click(function(event)
{
if($(event.target).is('a'))
{
$(this).//do something
}
}
I'm binding a click event to a div so that I can see whether is was the div or some element inside the div that has been clicked. When the if() in my code evaluates to true $(this) is still equal to $("#content") whereas I'd like to have the clicked anchor as matched element. How would I do this?
View 2 Replies
View Related
Sep 8, 2011
Are there any difference between class selector and ID selector
View 2 Replies
View Related
Jul 25, 2010
I've got a scenario where i've got a list of text names on a page and a rotating gallery of images. Each image relates to one of the names. What i would like to do is highlight the name by adding a css class or id when the related image comes into focus.
I'm sure i can do this by using the rel element to relate to the id of the image (or the other way round!) but i'm not sure exactly how. I presume it's using jquery live and matching with selectors.
I'm using jquery and the galleria plugin.
View 2 Replies
View Related
Mar 9, 2010
I need to know how to reload a component using jQuery, i got 2 selects in a page the 2nd one is populed by the 1st one value, how can i reload just the 2nd select w/o reload whole page?
View 1 Replies
View Related
Sep 15, 2011
I have multiple selects on a single page like...<select name=select1 id=select1>
<option value="val1">Val1</option>
<option value="val2">Val2</option>
<option value="val3">Val3</option>
</select>
<select name=select1 id=select2>
[Code]...
Each one belongs to a student so the # in the select name/id = student_id. I want to set a value in a text box based on the value selected for that particular student.
Rather than having a script for each select, can I make a single script that can determine which select was changed and then change the text box accordingly?
View 1 Replies
View Related
May 3, 2010
i have a web service at this url http:[url]....i use hotel search file with HotelSearch method and method will retrieve xml file contains the matched data. the varialbe that i made post with it is named : HotelData
the data of the variable is a string file that contains an xml data like this
<HotelsParameters>
<CityID>388</CityID>
<UserName>admin</UserName>[code]....
the data in input filed is the previous xml file
View 4 Replies
View Related
Mar 20, 2011
I was trying to do something similar to code highlighting but can't find a good way to do it. For example lets take this code:
def some_function():
something()
somethingElse()
def some_other_function():
something2()
somethingElse2()
[Code]...
View 3 Replies
View Related
Jun 5, 2009
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?
View 2 Replies
View Related
Aug 15, 2011
how can i cath a html <select> event? i have a <select> list... i want to catch the value of <select> when a user selects an option..
View 2 Replies
View Related
Sep 30, 2009
I'm using the jquery autocomplete plugin.Suppose the user starts typing, and the autocomplete presents a drop-down of possible values. If the user presses return, the first valuein the drop-down is selected.What I want instead is the user experience that Firefox's search boxprovides: As the user types, search suggestions are offered. If theuser presses return without selecting a suggestion, what the user hastyped so far is submitted. And of course, if the user does explicitlyselect a value from the drop-down, then the selected value is
View 1 Replies
View Related
Oct 23, 2009
I have a table that contains a select element like so
<tr><td>key value in hidden input</td><td><select>options</select></
td></tr>
I need to set
$("selectclass").change(function() {
//Find the value of hidden input in 1st cell of row of the select
list that was changed.
});
So when a user changes the option of the select i need to get the new value the option has been changed to plus the value from the hidden input and submit them via ajax to a method on the server. How can i get the hidden inputs value?
View 1 Replies
View Related
Mar 25, 2011
I have a jquery function that will show or hide a div id="hide1" based on the result of a select id="ticket1"
$(document).ready(function(){
$('#hide1').hide();
$('#ticket1').change(function(){
if(this.value == 'adult'){$('#hide1').hide();}
[Code]....
It works well! But my script actually clones elements of the form so a user could be selecting adult or child for a number of tickets - ticket1,ticket2,ticket3....
How can I adapt that script so that it will show/hide for each ticket
View 4 Replies
View Related
May 7, 2009
I have everything working accept the last part and I don't know what to do.function show() works and shows data entered in text box.function open_win() works,but I only need it to open when there is a input match say like the name Tom,otherwise I want function show() just to show the input.
Currently the new window opens every time the button is pressed needs to match input string only before window opens and then string print to window I think these two lines are the problems(whatever the input) document.getElementById('myDiv').innerHTML = string; And var bselect= "Tom" open_win(); I think I need to set var to the string printed to page to solve the last part. how to I get the blank window to the center of screen,as it covers the data in the function show.
Below is my code thus far :
<html>
<head>
<title>Input</title>
<script>
[code]...
View 4 Replies
View Related
May 27, 2011
I'm currently using h5validate with my forms but recently setup a few where a second form is generated based on what a user selects from a dropdown menu (via AJAX). Since the new form ID's were not existing when the document was loaded jQuery does not bind h5validate to the new form. I found a plugin called livequery that will bind new elements on the fly. Unfortunately, I'm pretty new to jQuery and can't quite figure out how to make this work with h5.
My current h5 function looks like this, where formID is the ID of the from that does not exist but is later loaded in via AJAX.
Here are the sites to the two plugins:
View 2 Replies
View Related
Jun 13, 2010
I have a scrollbar that I programmed. It is just like a scrollbar in a browser - click on the scroller and while holding the left mouse button you drag the scroller to move the window.
These are the issues I am having: if the target I use to be the scroller draggable target is an image, the image when clicked and dragged will be dragged as if I was trying to pull the image onto my desktop to be copied.
- if the target I use to be the scroller draggable target is text within a div, then sometimes it will select the text as if I was selecting to copy/paste
- sometimes while dragging the div as a scrollbar, the speed of my mouse will 'beat' the REPEATED CLICK speed (and it is set very fast) and I will "DROP" the scroller.
- Also when dropping the scroller, the page will select EVERYTHING as if I am trying to select all of the content in the page (SELECT ALL) and everything turns blue.
[Code]...
View 2 Replies
View Related