javascript

javascript hide/show tabs using JQuery

Hey all, I have a quick question of how I can use jquery tabs (you click on link button to display/hide certain divs). The div id matches the href of the link: HTML links: <table class='layout tabs'> <tr> <td><a href="#site">Site</a></td> <td><a href="#siteno">Number</a></td> </tr> <tr> <td><a href="#student">Student</a></td...

jQuery infinite loop w/ tablesorter

Got myself in a funny situation: page has three tables. Using sortEnd, any time you sort one table, it sorts the other three. However, since I bound sortEnd to the function that does the sorting, you get a infinite loop of sorting/resorting. It looks like: $("table.tablesorter").tablesorter({widgets: ['zebra']}).bind("sortEnd", function...

IE only jQuery bug

demo for reference: http://greg-j.com/static-content/accordian/ When viewed in any other browser, the toggler works as you would expect it to. However, in IE (I'm using 8), you can only contract the currently expanded sub menu, and then you get undesired results once it is closed. Example html: <!DOCTYPE html> <html> <head> <script cl...

simplemodal or my brain bug?

Sorry for my Eng. I`m trying to use simplemodal in my project authorization form, but here is a little trouble: <javascript> function usr_init() { $('div#usrinfo').html("test"); } </javascript> <html> <a href="#" onClick='$("#authdiv").modal();'>TEST!</a> </html> In authdiv I have a form with onSubmit="usr_in...

How to find out the name of the root element?

Suppose I have downloaded a valid XML document via Ajax (var docum = request.responseXML;). Now how do I find out the name of the root element? ...

Changing the window title when focussing the window doesn't work in Chrome

I'm (ab)using the document title as some kind of a notification area. If the tab/window in question doesn't have focus at the time I want to notify the user of something, I change the window title to include some notification. When the window/tab comes back into focus, I want to remove the notification, i.e. reset the title to standard....

Displaying fancy routes in cloudmade based service

I look for a way to display a route in a fancy way using the Cloudmade service. Currently, I can see computed routes like on this tutorial http://developers.cloudmade.com/projects/web-maps-lite/examples/routing, but I look for a fancier way to do it -- without A and B tags, and with colors, etc. Is this possible ? Thanks for your hel...

in javascript, best way to Remove Non Numeric characters from the Beginning of a String?

-_1234d5fr should ideally turn into 1234d5fr Thank you so much! ...

IE8 blocking JavaScript Cookies

Hey there folks, Here is one that is throwing me for a loop. I am trying to set a simple cookie that has one name:value pair on IE8. Tested on FF and it works fine. IE8 keeps blocking it. I have read about the P3P stuff and created a basic P3P doc, no errors reported by the IBM tool, and added the following on all pages: <meta http-eq...

How to find out if an XML document contains a certain element (by tag name)?

Suppose I have downloaded a valid XML document via Ajax (var docum = request.responseXML;). Now how do I find out if it contains a certain element (by tag name)? ...

javascript, jQuery: how to save values instead of the references

hi, I'm using the following lines to store the location of an object. var lightboxTop = $('#lightbox').css('top'); var lightboxLeft = $('#lightbox').css('left'); I'm successively moving this object in my element, and I want to restore it previous position with the stored variables. But, I'm afraid javascript is saving the values by ...

Any way to define getters for lazy variables in Javascript arrays?

I'm trying to add elements to an array that are lazy-evaluated. This means that the value for them will not be calculated or known until they are accessed. This is like a previous question I asked but for objects. What I ended up doing for objects was Object.prototype.lazy = function(var_name, value_function) { this.__defineGetter__(...

Select Element from a div tag

How can I select the first tag with center id name in sample below code? <div id=first> <div id=center></div> </div> <div id=first> <div id=center></div> </div> ...

assigning variables to DOM event listeners when iterating

I'm thinking there's some basic stuff that I'm missing here; for (var i=1; i<=5; i++) { var o = $('#asd'+i); o.mouseover(function() { console.info(i); }); } When hovering over the five different elements, I always get out the last value from iteration; the value 5. What I want is different values depending of which element ...

Does the jQuery .unbind() method only work on jQuery created events?

I am trying to unbind all event handlers for all elements that are inside a particular container. Like a DIV. But those events have been bound/registered not using jQuery. Some are bound the manual way with onclick="...." or using regular native JavaScript. But when I do something like this $('#TheDivContainer').find('div,td,tr,tbo...

Find all CSS rules that apply to an element

Many tools/APIs provide ways of selecting elements of specific classes or IDs. There's also possible to inspect the raw stylesheets loaded by the browser. However, for browsers to render an element, they'll compile all CSS rules (possibly from different stylesheet files) and apply it to the element. This is what you see with Firebug or ...

Loading xml with Jquery - why doesn't this work

I have regular javascript code and am trying to utilize JQuery just to load and parse an xml file. I have the following: function loadXml() { $(function() { $.ajax({ type: "GET", url: "my_file.xml", dataType: "xml", success: parseXml }); }); } func...

Is Javascript only available for web browsers?

I would like to know about JavaScipt. Is Javascript available only for web browsers? Because I used some JavaScript code for Firefox Plugin development and Thunderbird. Help me to find out more about this: where can I use JavaScript other than web browsers, and how? ...

Get ID of clicked on element in function

I want to get the ID of an element I click on. I put the function in the onclick element, like this: <a id="myid" class="first active" onclick="markActiveLink();" href="#home">Home</a> And this is in the function: function markActiveLink() { alert($(this).attr("id")); } This doesn't work, as it says it isn't defined. Does it...

Preventing an <input> element from scrolling the screen on iPhone?

I have several <input type="number"> elements on my webpage. I'm using jQTouch, and I'm trying to stay fullscreen at all times; that is, horizontal scrolling is bad. Whenever I click an <input> element, the page scrolls right, showing a black border on the right of the screen and de-centering everything. The inputs are offset from the le...