JQuery :: Get A Specific Class From Several Classes On An Element?
Jan 10, 2011
I have a div with several classes on, like this:
<div class="class-one class-two special-class"></div>
I want to get the class that starts with 'special' and store it in a variable...but I am having trouble doing this...I can get as far as storing all of the classes in a variable:
var myClasses = $(this).attr('class');
...but I now need to extract just the one class that starts with 'special'...
View 4 Replies
ADVERTISEMENT
Jan 17, 2011
This can't be too hard, but I'm not seeing the answer. Elements on a web page may contain a class starting with "tr_". Sample HTML:I'm using the following to select matching elements: $('[class*=tr_]').each(function() So far so good. But now, I need to get the name of the class that starts with "tr_" from each matching element.
View 2 Replies
View Related
Jul 18, 2010
How is it possible to get the class starting by 'date' of a specific element?
e.g. <p class="hello date123 world"></p>
I would like to get the class date123
View 5 Replies
View Related
Nov 6, 2010
On my website I have a lot of entries which are similar to blog-entries. Every single entry has about 500 signs and if there are more than there is supposed to be a button "read further"(atm there is no button but later it will be). If the user click this button, the remaining text of the entry is supposed to slide down. My problem is now that I don't know how to slide down just one article. Every article looks like this:
<article class="dark">
<div class="text"><h2>Title</h2> .....
<div class="slide_text"> .....
</div></div>
</article>
But how to slide down only the "slide_text" which belongs to the clicked article. If I use:
$('article').click(function() {
$('.slide_text').slideToggle(200);
});
Every singe "slide_text" of all the entries appears. But this is not, what I want. Is there a way to toggle just the child-slide_text of one entry? Or do I have to give every entry an id to define which entry is supposed to toggle?
View 1 Replies
View Related
Apr 25, 2010
I want my script to loop through all the list elements and when it sees a class name of "more services" an alert window should pop up. The alert is so I know i've done it right-which I haven't.
Currently my code looks like this.
Code:
<script type="text/javascript">
var serviceList = document.getElementsByTagName("li");
for (var i=0; i< serviceList.length; i++) {
if (serviceList[i].classname == "more-services"){
[Code]...
View 10 Replies
View Related
Mar 10, 2010
<div class="box top"></div>
<div class="box main">
<div class="box header">
<div class="badge"><ul><li class="active"><span>60</span></li></ul></div>
[Code]....
What is happening is $(this) is no longer based on .expand being the (this) that is clicked.
like if i have a button SOMEWHERE randomly on the page with this
<div onclick="Minimize('_alerts');">Click Here</div> this will minimize alerts but because the (this) in minimize function doesn't actually point to the right button that I want to add a class to.
Is there a way to modify the minimize function so that it finds the <div id="mytoggle"><ul> <li class="expand boxminimize" rel="_alerts"> using the rel toggle, and then changes the class of the li from expand boxminimize to boxexpanded??
just like the .expand click function I posted on the top of the post that works?
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
Jun 16, 2009
How do you get the first element when the element got multiple classes?
View 6 Replies
View Related
May 24, 2011
I am fairly decent with JQuery, but there is always more to learn of course! Consider the following structure.
<div class="container">
<div id="label1">
<div class="label1_1">
[code]....
View 1 Replies
View Related
May 21, 2010
I made this small piece of code, and I think I made it in a very drawn out way. I am sure there is a lot quicker way to do it. I want all divs to be cleared that are in a certain div. So when one link is clicked, the visible div is replaced with the new one (depending on the link)
Here is the code I have done...
$(document).ready(function(){
$(".untitled1link").click(function(){
$('.untitled1, .untitled2, .untitled3, .untitled4, .untitled5_1, .untitled5_2, .untitled5_3, .wall, .lightswitch, .detritus, .untitled6, .table, .socket, .socket2').hide();
$(".untitled1").fadeIn('5');
});
});
I just need a way to say clear all in that certain div, rather than having to name each class. I was thinking of giving each of those another class which is uniform across them all. But I don't think you can have two classes.
View 2 Replies
View Related
Apr 22, 2010
I'm using this bit of jQ to add a class to two different elements based on the class of another (parent/grandparent, etc) element.
First, when there's no class at all in <div id="main-content">, the 'active' class is added to *all* the #nav-primary LIs, and also to *all* the #aux-left DIVs; how can I modify this so that in the absence of any class on #main-content, do nothing?
Second, how can I target only the first or second of multiple classes to store in the 'containerClass' variable, e.g., <div id="main-content" class="apples bananas">?
View 2 Replies
View Related
Oct 27, 2011
How do I get href links from classes & append/prepend them to some element. My attempts...& many other I can't mention
[URL]
View 12 Replies
View Related
May 17, 2010
i have got about 50 definition lists on one html-page witch all look linke this:
<dl>
<dt class="title">aaa</dt>
<dd class="subtitle">bbb</dd>
<dd class="city">ccc</dd>
<dd class="email">ddd</dd>
<dd class="website">eee</dd>
<dd class="description">fff</dd>
</dl>
if the dt-element in one of the definition lists has a specific css-property (e.g. length > 100px) then the dd-element with the css-class "subtitle" in the same definition list should be removed.
View 2 Replies
View Related
Jul 2, 2009
I am new to this discussion but hope you would post reply for my query and encourage me to keep in touch with this discussion. Well here is my problem. I have made an edit in place form in which we can add and remove the elements. I have used jquery.jeditable.mini.js and jquery.duplicate-remove.js plugins for edit in place and add and remove action. I have live() function to access the dynamically ganerated elements like this. $(".addressDiv span").live("mouseover", function(){
clickable function here...
[Code]...
View 1 Replies
View Related
Jan 9, 2012
My DOM structure in HTML page have some elements 'IMG'. One of 'img' element have attribute 'src' = 'lolo1.jpg'. How can i find the 'DIV' element with this specific 'img' element inside? I have to find nearest 'DIV'.
[Code]...
I wanna write function like a GetNearestDivID('lolo2.jpg') which would give me result 'mix2'
View 1 Replies
View Related
May 9, 2010
Suppose I have the following HTML code:
<div class="one">
<a href="http://jquery.com/">jQuery</a>
</div>
<div class="two">
[Code].....
Basically I want to recognize which <div> tag was double clicked, and hide the corresponding link that is nested within that specific <div> tag.
The only way I can think to do this currently is to basically copy and paste a whole bunch of jQuery code for each <div> tag and it's sub-elements (links in this case).
View 2 Replies
View Related
Jun 11, 2009
I'm a novice here, and I've got such a piece of code:
$(document).ready(function() {
$.each(includes, function(index, value) {
$('ul#menu-list').append('<li id="' + index + '"><a href="#">' + value + '</a></li>');
[Code]....
Basically, I load an html document on demand, through a menu populated with 'includes' values. Clicking on any item on the menu will load the appropriate document in the #content div and add an 'active' class to the menu item itself, to highlight it.
The loaded document optionally has inline links, that should load documents based on the same id's. Clicking on these inline links loads the appropriate document, but the 'active' class won't be added to the menu item having the same id of the inline link.
The thing I don't understand is that if I put (look at the line with arrows) any other value than 'id' (any valid integer or even 'id * 2') I get the desired result: a menu item having that id gets highlighted, a class being added to it.
View 3 Replies
View Related
May 7, 2010
I have an assigment of statistics formulas in java i have calculated the classes class intervals and boundry but i am unable to find out the frequency.........
String ans;
View 3 Replies
View Related
Sep 24, 2010
I've got a list of modules, and when I click on one of them it expands displaying the content. When you expand them, a little image on the right changes from a down arrow (v) to an up arrow (^), but it's changing on all of the modules rather than just the one.
Here is the website: [URL]
It's pretty obvious what my question is; how do I get it so the image only changes on the module that you expand?
Here's the code for the moduleToggle function:
function moduleToggle() {
$('.content').hide();
$('.title').click(function() {
[Code]....
View 3 Replies
View Related
Jan 23, 2011
I have several table rows with the class name "recs", each containing a cell with the class name "data".Now I want to copy the text inside the table cell into a text box whenever I click on each row. For example if I click on the second table row, the name "David" would be copied in the textbox "name"
[Code]...
View 1 Replies
View Related
Mar 8, 2011
I'm building a volunteer translation site. In order to constantly update only paragraphs that multiple translators are working on, I need to pass an array to PHP of A: which paragraphs are open, and B: which translations have been submitted and are visible on the user's screen. PHP will then compare this with what is in the database and tell jQuery to add new submitted translation paragraphs or remove deleted ones.I've managed to make a string of all the open Div's and have it updated every second, like this:
function cycle(){
var data = '';
$('.paragraphtobetranslated:visible').each(function(){
[code]....
View 2 Replies
View Related
Dec 3, 2011
I'm trying to set up a simple load function to bring in some specific class content from pgB into pgA.Here's the code in html in pgA:
<div id="bext"></div>
<script type="text/javascript">
var $j = jQuery.noConflict();
[code].....
View 30 Replies
View Related
Jun 28, 2006
How can I get a list of all the css classes applied to an element?
document.getElementById("someelement");
someelement.?(classlist)... blah
View 5 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
Nov 17, 2011
I have a large number of "li"s with the same class - i.e;
<li class="month01Days"></li>
:
:
[code]....
View 1 Replies
View Related
May 26, 2010
I just donīt know the right syntax for this:
I want to change the css class of the li element from the name hidden to the variable filterVal, but i donīt know the right syntax.
View 1 Replies
View Related