jquery

Jquery. Why this doesn't work?

This is html code: <a class="cat" href="#">category</a> <span class="kiti" style="position:absolute; padding:5px; margin-left:-18px; display:none; background-color:#000"> <a href="#">sub1</a> <br /><a href="#">sub2</a> </span> And functions...

jquery / JS allow only numbers & letters in a textfield

What would be the easiest way to allow only letters/numbers in a textbox. We are using JS/jQuery, but don't want to use a validation plugin? ...

li click events on safari?

This issue is specifically with Safari. <div id="list"> <ul> <li onclick="do_something();"><!-- block with stuff in it --></li> </ul> </div> When the above is loaded normally, the onclick applies to the entire li block. The problem is, later on when I use ajax to populate the #list div dynamically... $("#list").html('...

How to cache the result of $.post-request in jQuery?

I have a small jQuery script that gets information by looking at an ID. What is the best way to prevent that the same data are requested more than once (e.g. what's the best practices for caching in jQuery)? I have tried to use $.post and $.ajax with option "cache" set to true, but the request is being sent more than once. Is it bette...

JQuery hover function causes my div to hide

In my functions.js I have: $(document).ready(function() { $("#cat").hover(function() { $("#kiti").show(); }) $("#kiti").mouseout(function() { $("#kiti").hide(); }) }) Html file: <a id="cat" href="#">category</a> <div id="kiti"> <a href="#">sub1</a> <br /><a href="...

select text on focus

ive got this function and it works to select text on click function select_text(ev) { if (this.createTextRange) { // This is for IE and Opera. range = this.createTextRange(); range.moveEnd('character', this.value.length); range.select(); } else if (this.setSelectionRange) { // ...

How to use jQuery Validation plugin with metadata and the jQuery Forms plugin (with some xVal as well)

I've been doing some development using the xVal framework for .NET to link up some of the validation rules for models on the server side along with some client side validation using the jQuery Validation plugin along with the jQuery Form plugin for submitting the form. The scenario is the following: Allow the client to perform basic v...

jQuery animation / hover and fade

This is my index.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd&quot;&gt; <html> <head><title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="style.css" rel="stylesheet" type="text/css" media="all"> <script type="tex...

Show ajax loader image until an actual image is loaded

So I have a page with little picture thumbnails on it and one big area in the middle of the page for full size photo. When user clicks on a thumbnail, a full size picture is shown in the middle of the page. I just change the src attribute of the image in the middle like this to achieve that: $('img#fullsize').attr('src', path); // path...

jQuery incompatibility with Firefox

Hello, I'm using a simple piece of code $("container").load(url, function(){ callback();}) to replace the content of a div container using jQuery's AJAX functionality. That appears to work well with Internet Explorer, however after trying to view it through Firefox I am getting some unexpected behaviour. The page is fetched and plac...

jQuery(this).val() not returning the value of the selected option

I have the following script at the end of my page: <script type="text/javascript"> jQuery.noConflict(); jQuery(function() { jQuery('#optElem').change(function(){ jQuery.post('http://example.com', { 'id1': 1, id2 : jQuery(this).val() }, function(data){ jQuery('#abc').html(da...

control initial enabled state for ASP.NET dependant controls that are enabled/disabled by jQuery

So far, I've seen (and I'm using the following) scripts to show/hide a div or other controls depending on another control in ASP.NET $('[id$=myRadio_0]').click(function() { $('[id$=myDiv]').show(); }); $('[id$=myRadio_1]').click(function() { $('[id$=myDiv]').hide(); }); and of course, my div in html like <div id="myDiv" runat="serve...

Determining how big an element will be in Javascript

I need to position an element in the exact centre of the page (using fixed positioning) and need to calculate the expected size. For example I would add HTML like this: <div class="window" style="left: X; top: Y"> <h3 class="title">Title</h3> <img src="file.jpg" width="300" height="200" /> <div class="controls">Some stuff</d...

One-by-one jQuery scrolling loader acting up in WebKit

I've been working on a little experiment where, as you scroll, new entries are loaded onto a page. You can see a practical example here. Now, if you look at this Firefox everything works as it should. As you scroll towards the bottom of the page entries start to load but only one-by-one. View it in WebKit and instead it will start to l...

jQuery: append form input

Hey guys, here is my html output: <script language="javascript"> function append_suggestion() { $('input[name="cn"]').append($('#rand-character').val()); } </script> <form name="form" action="/search/results" method="get" class="search-form" id="search-autocomplete"> <input size="28" class="search-field" id="cn" name="cn" typ...

How do I access a SPAN element using the PREV function in JQuery?

When a button is clicked it needs to look before its ocurance and find a specific span tag. Unfortunately it is either not finding the tag or not changing it's contents. This is the code that doesn't work. $(this).prev("span[id*=CommentText]").hide(); I can set the colour during the load event but when the link is clicked it won't m...

jQuery qTip: How to attach a single tooltip div to multiple target divs?

The normal behavior for the jQuery qTip plugin is to create a new hidden div for every tooltip item assigned. Is there a way to tie a single hidden tooltip element to multiple targets, to avoid cluttering the DOM? Contrived Example: <div id="foo1"></div> <div id="foo2"></div> <script> $("#foo1,#foo2").qTip({"content":"test"}); </scrip...

Refactoring Javascript

I have a lot of code in the admin area of my site that is, basically just CRUD operations using AJAX posting. I was wondering if you had any tips on refactoring these type of functions either into generic functions or classes etc. Here is some sample code, though a lot of this is duplicated in other functions with just different ajax p...

How can I load data on a page based on this being added into the URL #a=1380369&i=23007472

On a php page with javascript (jquery) in the urel I would like to have something like this idex.php?var=something*#a=1380369&i=23007472* The page will load photos and have a next and previous link, when this is clicked on it will use ajax to load the new image into the page but I need to also change the URL to add someting like this ...

Javascript header equivalent in JsTestDriver/Javascript testing

Hi all: I want to insert a function before the DOM or jQuery's document.ready loads in my JsTestDriver test file. I tried inserting it in the setUp function, but upon alerting the length of document.ready list in the first line of code, the document.ready has already been loaded. I have tried inserting tags to it, but JsTestDriver doe...