I am not terribly familiar with Javascript but i am looking forward to learning, and currently the problem I am facing is this:I have an a file being included to an .shtml document, that serves as my navigation, the code is like this:
getting all the header text:jQuery("#accordion h3").text();how do you get the active index? and how do you use that index to get the active header?how do you get the header text for the active header?
A REALLY simple example, surprising to me this doesn't work...
This is my php code:
And here the html from which the php-script is called:
Here's supposed to be the output: <div class="output" id="output">test</div>
The text "test" inside the div gets replaced by nothing. and if i use the line i commented out instead of " $('.output').html(data)", i get the following output: "[object XMLDocument]"
Btw really susprised to see a forum on a website like this without proper code-tags with monospaced font...
I have a login button which takes the user to the login page. Now... this to me seems like a slow way of logging in. I would like users who have javascript enabled to click the login button. Instead of them being forwarded to the login page, I want the login form to magically pop up on top of the web page.
I can do this, I can creative a div, add the html and probably with a bit of trying - get the user to login. However I have a question. For maintainability, I want to have create a separate HTML file, how would I insert this into my page using Javascript?
Furthermore speed is crucial, is there a way to have this fragment load in the background on every page? I am not sure what would be best, i just don't want a second or two wait when the button is pressed. Basically - in short - how to I load this file fragment? What is the fastest way to do this?
The above is a simplified example of the problem I'm facing. I could merge functions into one big self-referencing function (i.e. recursive function), but that's ugly and causes other problems (such as when insert form elements and wanting to harvest the user input afterwards). I considered declaring a variable in the top ".ready" function, and have all child functions stuff their HTML changes in it, but that seems to be a pain to keep track of and removes much of the value of using jQuery in the first place...
Is there a nice solution for this? To, after inserting HTML, somehow update the HTML state referred to by jQuery in the non-local scope(s)?
I tried this code in [URL]... jquery reports as 4 elements in firefox/chrome browsers correctly where as 0 in internet explorer 6.0 How do i fix this? Should I report this as bug?
I am loading an entire page in ajax, but I just want to load a fragment from it. Using the .load() function, you can do this by adding a selector after your url like 'getPage.php #myDiv' etc, how to do it using the .ajax method.
I'm trying to get the "d1" div to be populated with the contents of the "my2" div on the second page. I don't want to use the .load() function, I want to use the .ajax() function. I can get this to work if I just use: $('#d1').html(data); instead of $('#d1').html($(data).find('#my2')); but the former results in the entire html contents of the second page being placed into the "d1" div, and I only want the fragement.
I'm using the following code (simplified version) to call a Json file, parse it and on each iteration, create a div with an ID of "tab". I'm using this with jQuery UI .tab() to create a listing with entries which have three tabs. Anyhow, the principle seems to work except that when I examine what's happening behind the scenes using Firefox console, I see that each href in the html code produced is causing the Json function to re-fire using the href as it's url target.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>
I think this is just a dumb question, I'm missing some basic logic here about jquery "grammar".
I'm trying to do an image swap on hover that checks to be sure the thumbnail is not the active thumbnail. So mouseover, it swaps. Mouseout, swaps back, unless the thumb has been clicked.
Here's a snippet of the code that doesn't work:
How do I check that _li is not ".active" and replace the src if it isn't?
I'm trying to embed an HTML fragment from one web page into another web page, using AJAX (as the fragment will change frequently). I'm using prototype.js for AJAX.
I've managed to fetch the HTML content of the slave page, but I can't figure out how to get just the part I want from the XML string returned in the AJAX request. The prototype.js AJAX function just returns a text sttring that I need to parse...but how?
Child Page: hello.html
Code HTML4Strict:
I want to include the <h1>Hello</h1> in the parent page.
Parent page: demo.html
Code JavaScript:
Obviously it's the fragment = resultDoc.getElementByClassName( source_fragment_name ); part that I'm having difficulty... It may not even be the right function - HELP.
The resultDoc=parser.parseFromString(transport.responseText,"text/xml"); seems to work, because the subsequent alert() works fine, but how do I get the page fragment identified by the source_fragment_name.
The alert("Fragment = " + fragment ); never happens, so the previous line has serious problem.
So, just to clarify, I simply want to parse the content out of one page, and embed it into another, in real-time, using AJAX.
Is there a way to load more than one html fragment using .load()? That is, I want my homepage to pull in multiple pages of content into the main page so that I can create a one-page site that slides vertically.
My question today is involving the accordion. I would really like to get rid of the highlight when I click on the tab, but nothing I have done works so far. I'm not sure of what I should do... this is what I have so far.
adding a class to an active li. I'm working in drupal, and the system adds a .active class to the DOM of whatever li class was last selected.In my .js file I added the following:
$('document').ready(function(){ var tabActive = $('#tabs-tabset ul.primary li.active a'); tabActive.addClass('tabknotch') });
This works perfectly...for the first tab. when I navigate to the next tab the class does not change. I thought maybe there's a variable in the dom that is causing the class to not move, so I tried narrowing the div that it looks for and tried this:
$('document').ready(function(){ var tabActive = $('li.active a'); tabActive.addClass('tabknotch') });
This achieved the exact same results...so there's obviously something I'm missing, but don't know what it is. If it's any help, here are two examples of the generated DOM that occurs when clicking on the active li. The first example is the div that has the class added, and the second is a div that does not have anything added. <li class="overview ui-tabs-selected active first tabknotch"><a href="#overview"><span class="tab">Overview</span></a></li> (this is the active tab where the jQuery succesfully adds the "tabknotch" class)<li class="features ui-tabs-selected active"><a href="#features"><span class="tab">Features</span></a></li> (this is the active tab that does not have the class added when clicked. When this li is active knotchtab remains on the other li that no longer has the .active class attributed)
I have a single page website and I would like to add an .active class to my links when I reach a certain point on the page (this will be done by unique div or section id's). The classes are currently empty, so I would need to be able to remove and replace the .active class accordingly.
Having a navigation menu desighned in photoshop, how can I use jquery to add a active state class to my css which can use the same hover style for active menu?
I am using jquery accordion where multiple accordions can be opened by user. I added onclick event to that adds source to an iframe within that accordion when user clicks on it. However I want to only load the source into the iframe when an accordion is opened...currently I load the source into the iframe even if they close the accordion.Example:<div id="toggleboxes" nclick="loadIFrame('iframe${iframe}','${mstrObject.firstChild.objectUrl}');">How can I determine if the onclick event on the above div is for open accordion action only?The code below returns object object. I am quite new to jquery and have been scratching my head for a bit regarding this. Does anyone know how to achieve this?I tried the following:var active = $( ".selector" ).accordion( "option", "active");Here is my loadIFrame function.
function loadIFrame(iframeId, reportUrl){ //getter var isActive = $( ".selector" ).accordion( "option", "active");
[code]I've got a long navigation, and pages slide in and out of view.Troubles are, if the user impaitently clicks a load of links while the page loading and sliding in is happening, it melts my (probably poorly written) code.So, I'm trying to stop the user from clicking on any other buttons,while the page loader is doing it's thing.
I have a problem where I want the menu with 'active' to be opened, belew is the script and source I have.The accordion works fine, but just does not open on the active page,
So basically I have this menu, the only problem I have is that I would like the colour of the text depending on which the 'LavaLamp' Image is when loading up to be red. For example when loading up this website (my url to the menu) [URL] I would like the text 'Home' to show red, since it is the active tab on page load.
I am attempting to set it so that upon clicking a link within this Joomla site (from the navigation menu), the link will become bold. I have already implemented CSS for ".active" and set the "LI" class to 'active' to the first class.
I have done a search for the JQuery code to do this, but each example that I tried did not work at all. The class remained to be on the first link, home.