JQuery :: Removing Some Items Of A Class & Keeping Others?
May 13, 2009
I have several conditional select boxes that populate from a database, using .ajax(). When the first select has an onchange, the second select populates normally. The same goes for the second and third selects. When I change the value of the second select box, the third box drops all dynamically created options and repopulates. When I change the value of the first select box, I can only empty the second box and repopulate. The third and future boxes keep their values.
The delete and repopulate piece of my function uses this bit of code: var dynamic_options = $("#" + next_dropdown_ID).children(".dynamic_option"); if ( dynamic_options ){ $("#"+ next_dropdown_ID + " .dynamic_option").remove()};
where next_dropdown_ID is the ID of the child select box. I've played with .find() and .filter() but the results are always either (a) ALL options with this class are removed, including the select I'm currently in, or (b)NO options with this class are removed.
Is it possible to delete ALL options on the page that have the ".dynamic_option" class, except for the children of the select box I'm currently in? I was hoping to be somewhat dynamic about it and not have to write an IF statement for every potential select box, so the code will be reusable. I can post the full function and HTML if more context is needed.
View 2 Replies
ADVERTISEMENT
Jun 3, 2009
I'm trying to dynamically create and remove items from a list, it works just fine. Sort of, I can remove items, and create items, but once an item has been created, I cannot remove it again, but I can remove the items present when the page loads.
Here is my code
<div class="list">
<div class="item">
<input type="text" value="" /> <a href="" class="removeitem">Remove this item</a>
</div><div class="item">
<input type="text" value="" /> <a href="" class="removeitem">Remove this item</a>
</div><a href="" class="additem">Add item to list</a>
</div><script type="text/javascript">
// Add item to list
$('.additem').click(function(){
var template = $($(this).prev().get(0)).clone();
template.insertBefore($(this));
return false;
});
// Remove item from list
$('.removeitem').click(function(){
$(this).prev().parent().remove();
return false;
});
</script>
I can remove the 2 original items, but when I create new ones, they cannot be removed.
View 1 Replies
View Related
Aug 30, 2011
I would like to have two columns, the left column showing all available items with an add button. The right column showing all of the added items, and then adding these together to provide an order total, but with the ability for users to add to the quantity or remove from their order.I have the add item to order bit working on, and the sub-total is working.I started to try to add on add/remove buttons to the right #your-order column but am getting stuck.Every time a user adds another item to their order, more buttons are added, and I can't get the "remove item" button working.The page is located here:URL...Should I paste the jQuery code I am using here?
View 3 Replies
View Related
Nov 25, 2010
<input type="text" class="class1">
<input type="text" class="class3">
<input type="text" class="class2">
<input type="text" class="class2 class1">
<input type="text" class="class1 class3">
<input type="text" class="class1">
Given the above, how would I select those that HAVE class1, but NOT class2, don't care about class3
So what I want are the items on lines 1,5 & 6 How could the below be modified to achieve what I want, or do I need something completely different?
View 1 Replies
View Related
Aug 27, 2010
I have created a jquery accordion menu for a brilliant CMS called 'Concrete5' and all works lovely BUT I now would like the menu to stay open if a menu item is selected within the drop list.I have manged to create the following.....
var pathname = window.location.pathname;
var selecteda = $(".nav-selected a").attr("href");
// alert (selecteda)
[code]....
..but it doesn't seem to work.I'm not a JQuery GOD like most of you on here but I am trying my hardest The accordion menu I am trying to get this to happen on is Accordion Menu.
View 1 Replies
View Related
Oct 27, 2011
I have table that has four columns and many many rows. It is quite long. I need to add a special divider (border) between each td cell. I thought I could create a css style .border_right and apply it to all td cells using jquery addClass() and then remove the class from the fourth td cell in each row so it does not add to or affect the outside border of the table.
My question is, how do I remove the class from the fourth td of each row using jQuery? I figure there has to be a shortcut way (one or two lines) to do this using jQuery so I don't have to manually add a 'class="border-right"' to each td I need it on.
View 5 Replies
View Related
Oct 10, 2011
I downloaded a form that I'm trying to add some modifications to. I'm appending a class to a tag once the validation on a form input fails. But I can't seem to have it removed once the validation "passes"
HTML:
<ul id="formField">
<li>
<label>Phone:</label>
[Code].....
View 1 Replies
View Related
Jul 23, 2005
Is there a way to remove text portion from the HTML keeping the HTML
Tags using the browser, say javascript RegEx or something ?
I have seen lot of examples removing HTML tags to get the text but how
the reverse of it?
View 2 Replies
View Related
May 5, 2011
This is essentially the effect I'm going for:
function quickadd() {
$('.menu').addClass('red').delay(1000).removeClass('red');
}
So, from what I've gathered from the docs, this doesn't work because the addClass and removeClass functions don't observe the queue. How could I get around this and setup a function that will add a class, wait a second, then remove that class? Would it require me to go outside of jQuery a bit and use some standard JS?
View 1 Replies
View Related
Jul 7, 2010
Trying to get data from xml file. Got it. Trying add data in class.
$(this).find('Category').each(function(){
var menuItem = ($(this).find('Label:first').text())
$(".DfMenu").text(menuItem)
alert(menuItem)
There are 4 menu item. Alert shows up right but it add same data in all menus one by one. How can I add four different menu item in four divs that is using the same class.
View 2 Replies
View Related
Oct 14, 2010
I'm trying to have multiple divs with the same class acting a s a button. I need to handle the click for each one. I will be obtaining the name attribute and passing that in an ajax call.However, this only works for one of the divs on the page, am I doing something wrong?
$(document).ready(function(){
$('#mark_sold').click(function() {
var item = $(this).attr("name");
alert(item+'clicked');
});
});
I'm also going to need to know how to refresh an image, too. I will be updating an image in the ajax call.
View 2 Replies
View Related
Jun 16, 2010
I am having trouble displaying in an alert the id of the list item which contains an image.here is the structure of li
<li id="IDr">
<img src="ImagesDoneTimelessDSC_0483_Thumb.png" alt="Zombie"/><span>Description</span>
<img class="Pink" src="ImagesPinkBanner.png" alt="Pink Banner"/><span
[code]....
View 2 Replies
View Related
Sep 23, 2010
I have a list of links in a sidebar, each with an associated class name. When one of these links are clicked, I want to fade out all of the main content list items that do NOT have this class (ie - if I click on boots, I want to fade out the list items heels and sandals)
[Code]...
View 4 Replies
View Related
Jun 2, 2010
I'm trying to toggle the on and off class on list items but having issues it working.
I only want the 'on' class on the element that is clicked. So if another element in the list is clicked it removes the 'on' class from the one that had it to the one that has been clicked.
$(document).ready(function(){
View 1 Replies
View Related
Mar 28, 2011
I'm trying to create a list that contains items which are filters for a search. The list shows 10 items (max) on the page load. if there are more than 10 it changes the class of the elements > 10 so they are hidden, and a 'show more' link is appended. Now if the user has 'unhidden' the previously hidden items and then chooses one, I want the class for all those previously hidden items to change until the user has deselected that item.
[Code]...
Is there a better, smaller way to write this? It works for what i need currently, but there are future features im planning that will not be practical checkingindividualindexes the way i've done it.
View 5 Replies
View Related
Aug 11, 2011
I have a lot of information on my site that is in multiple categories. I have a list of categories, each with its own checkbox. By default, all the information is displayed (therefore all the checkbox's are checked by default).When someone unchecks the box I want to hide the divs with that class, and when someone rechecks the box, they should reappear. Here is my code so far. It is hiding the div's fine, but they are not reappearing when user tics the checkbox again.
<script type="text/javascript">
function toggledisplay(category){
if(document.getElementById(category).checked){
[code]....
View 2 Replies
View Related
Jun 5, 2010
i have situation that i need to remove table that is automaticly generated, but i also need to not remove contents of table.
<UL>
<table class="mytable" width="100">
<body>
[code]....
View 2 Replies
View Related
Jan 10, 2010
version of Apycom's jQuery menu; you can find itat http://apycom.com/ and it is looking really good.I have uploaded files, and published it on a test site - www.flexin.beUnfortunately, some of the submenus starting from the second that haschildren elements, it adds the item on the top level in InternetExplorer.Does anyone on this list has any experience with this library?
View 2 Replies
View Related
Jun 3, 2010
My code: [URL]... When I click on UpraviƄ in class edit I need add some HTML code to begin and to end of class entry how to I can select class entry in the same class post on which I clicked?
View 1 Replies
View Related
May 17, 2010
I need to keep a log in a test application, so I'm using a textarea for that, and I'm appending text using the+= operator.Follows the trace function which fills the textarea:
window.trace = function(s) {
if ($('#enableLogCheckBox').attr("checked")) {
var logArea = $('#logArea')[0];
[code]....
View 1 Replies
View Related
Sep 15, 2009
I'd like to know if there is a way to keep a table header fixed on top of a div while I scroll the table rows. I have a div high 200px and the table itself is around 300px so when I scroll down I'd like to always see the header on top. I already use for the table tablesorter so the solution must be
compatible with that plug-in.
View 14 Replies
View Related
Nov 24, 2010
I have around 30 check boxes in a form and I need to keep track of their status if they are checked or not and based on that change the data in the dom.
I am stuck on the logic of how to implement or code for 30 check boxes. I was using the below example code but there will be a lot of if statements as I need to always know what their status is. Is there a better way I can manage so many check boxes ?
if($(this).is(":checked"))
View 2 Replies
View Related
Jun 11, 2009
Can I remove div1 but div2 keep there?
<div id="1">
<div id="2"></div>
</div>
View 6 Replies
View Related
Aug 18, 2010
I'm working on a mysql browser / edit-in-place app which presents the user with a floating UI (think lightbox), that contains widgets appropriate for the given field they've clicked on.
Presently, rather than centering the UI element like a lightbox however, I find it best to keep it relative to their mouse, so that they don't have to traverse halfway across the screen with their mouse to interact with the interface if they've clicked something (for instance) on the bottom left.
The problem however should be apparent: if they click something towards the bottom of the screen, we need to adjust the css top/left properties so that the UI remains within the viewable area and doesn't run beyond the viewport, if possible. I've seen this done tons of times with tooltips.
I've thrown some basic awareness together using$(window).height() / width(), but if anyone could point me to a maturealgorithmfor harvesting the appropriate offset.
View 1 Replies
View Related
May 4, 2011
I am currently using:
$("ul.tabs li:first").addClass("active").show();
$(".tab_content:first").show();
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active");
[Code]....
There are 2 options I could use but I don't know how to do it.
1. Using a get parameter to select the tab
2. Using the cookie plugin (not sure how that works)
View 4 Replies
View Related
May 5, 2011
I have a huge blob of code but the main part I am focusing on is this
$('.billboard_click').click(function () {
//this remove class
$(".billboard_click").removeClass("billboard_click");
});
1. Execute a click event when the div with the class 'billboard_click' is clicked
2. Once clicked, remove the class from that very div to avoid another click from happening
3. Execute a series of events such as animations, etc
4. add the class back to the clicker div
The code does not seem to work as expected but I am wondering if I am having issues elsewhere at this point and wonder if this actually is known to work
View 7 Replies
View Related