JQuery :: AddClass Fails When Targeting A Specific Class Instance?
Nov 17, 2011I have a large number of "li"s with the same class - i.e;
<li class="month01Days"></li>
:
:
[code]....
I have a large number of "li"s with the same class - i.e;
<li class="month01Days"></li>
:
:
[code]....
My HTML:
<div class="home-button">
<span><a href="#" style="">Button</a></span>
</div>
I have an instance of a div (button), inside this div is a link wrapped in a span. When you hover over the div (".home-button")I want to move the background position inside its "span a", I've achieved this using the code below.
[Code]...
I am wondering if it is possible to get the response from a method
within a given page, and that function alone? Traditionally, I have
been getting the response from the Page_Load method of the targeted
page, but now I want the response from a particular method on the
target page:
Public Sub SomeCallback(ByVal sender As Object, ByVal e As EventArgs)
'RETURN XML FOR CALLBACK
End Sub
I have the following style markup:
<h2>
<span class="status">
UNDER OFFER
</span>
[Code].....
As i'm trying to add an overlay image to the hyperlink so it will appear on top of the image that is already there (css absolute and z-index).
I have been trying out image replacement on radio buttons and check boxes for styling forms. In this case I might have something like:
<label for="usd" class="currency">USD</label>
And using addClass
$(this).addClass('hover');
It turns into
<label for="usd" class="currency hover">USD</label>
The problem is that in IE6 if you were to have two custom radio button classes on the same page then the first one takes on the styling of the last one because IE6 can't figure out the chained class. Ideally I would want the class to be amended on hover toclass="currencyhover" instead so I could write a unique CSS class like .currencyhover instead of .currency.hoverIs there some way to use addClass and not have it add a space between the already existing class and the new one? If not, is there some way to trim it
<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?
I have a String instance which contains the name of a class. Is there some way I can instantiate that class from given the class name in the string?
View 4 Replies View RelatedI have a javascript object which dynamically generates a table adding, deleting and moving rows as the user clicks on buttons or links. Problem is when I generate a table row and add the javascript method call to my class, I have to put the object instance name variable of the class in order for it to be called from the onclick=function(). This is seriously limiting, but I'm stuck for a way round it. Heres a edited of the code so you get the idea....
Instantiating the object :-
var dtl = new DynamicTableList("table1", $
{myObject.allFieldsAsJavaScriptArray}, true, true, true);
My javascript class DynamicTableList, note the dtl javascript object
instance variable being referred to in the addRow function. How can I
avoid this???
function DynamicTableList(thisObjName, tableName, options, showDelete,
showUp, showDown)
{
this.processRow = function(r, row, up, down)
{
...
};
this.processRows = function()
{
...
};
this.getVisibility = function(visible)
{
...
};
this.delRow = function(button)
{
...
};
this.addRow = function(selection)
{
...
if (showDelete)
{
var cell2 = document.createElement('TD');
var inp2 = document.createElement('IMG');
/
************************************************** ***********************************************/
inp2.onclick=function(){dtl.delRow(this);} // Have to specify
dtc!!!!!!!!
/
************************************************** ***********************************************/
inp2.title='Delete'
inp2.alt='Delete'
inp2.src='images/delete.gif'
cell2.appendChild(inp2);
row.appendChild(cell2);
}
...
tbody.appendChild(row);
this.processRows();
};
this.moveRow = function(node, vector)
{
};
}
Obviously the code dtl.delRow(this); is being dynamically generated, but how do I replace the dtl instance name with something that'll work whatever the user of this class calls the instance of it!
I need to change the background-image (or possibly background-position) property of each new instance of a div with a particular class. I will have a set of images to choose from, or could create a sprite with all of the images.
Example:
Code:
<div class="desc">content</div> **needs background-image: url(pic1.jpg)
<div class="desc">content</div> **needs background-image: url(pic2.jpg)
...
etc.
The page code is dynamically generated from our CMS, so can't change the HTML.
Basically I have this code:
Code:
<div id="rightNews">
<div class="showHead">
<a href="#" class="showAcc">7th July 2010</a><br />
Lorium epsom diem Lorium epsom diem Lorium epsom diem
[Code]....
But when I click to expand one coloumn all of them expand as they have the same class, is there a way so the others close when another one is clicked?
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).
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.
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]....
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]...
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'...
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]....
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].....
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
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]...
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?
I'm using a function to load a page into a div. When I add the class of the element I want to show (.contentpaneopen) Chrome and Safari show no content. It works OK in IE and FF.When I ommit the class it works on all browsers.
function loadContent(elementSelector, sourceUrl) {
//Works in Chrome en Safari:
$(""+elementSelector+"").load(""+sourceUrl+"");
[code]....
Just getting my feet wet with AJAX and trying to figure out how I can make a javascript call to a specific PHP function in another file when I have a drop down menu change value using DOM. I've found lots of examples of how it could be done with GET variables, but none for this particular method of data retrieval. Has anyone ever ran into this, and if so, how did you solve this interesting deliema?
View 6 Replies View RelatedI 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]...
I am currently attempting to write a function that retrieves the name attribute from a list of items with a specific class name. To illustrate:
Code:
Show types of food:
<input type="radio" name="food" id="fruit" onclick="setVisibility('fruit')"/>
<label for="fruit">Fruit</label>
<input type="radio" name="food" id="vegetable" onclick="setVisibility('vegetable')"/>
<label for="vegetable">Vegetables</label>
<li class="art" name="fruit">pear</li>
<li class="art" name="vegetable">celery</li>
<li class="food" name="fruit">banana</li>
<li class="food" name="fruit">grapes</li>
<li class="food" name="fruit">orange</li>
<li class="art" name="fruit">grapes</li>
<li class="food" name="vegetable">lettuce</li>
<li class="food" name="fruit">apple</li>
<li class="food" name="vegetable">spinach</li>
<li class="food" name="vegetable">cabbage</li>
I would like create a function called setVisibility to iterate through all the list items where class=food and return the value of the name, so that I can compare that to the radio box, and set visibility accordingly.
I have following little script that applies to my entire html page:
$("td[id*='MSOZoneCell_WebPartWPQ']>table>tbody>tr>td").each
(
function()
[code]....
i have a xml document (static) that I need to test what is in a grand child element. The real application is a jqGrid. I have a onSelectRow operation going on. I can click on a row and get a response (in a alert window) for any root children. But how do I do this for anything deeper in the tree? A portion of my xml is attached.
[Code]...