a JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.

learn more… | top users | synonyms

5
votes
1answer
324 views

Optimizing and consolidating a big jQuery function

I understand this is a very vague question and a lot of code to look over. My question is basically: I have all these functions that work together to create functionality on a page: is the structure ...
1
vote
1answer
96 views

is there a way to write this shorter

i need opinion, is there a way to write this shorter $('#pietra_svg #p1_4 polygon#p1').click(function() { $('#apla_p1').fadeIn("slow"); return false; }); $('#pietra_svg #p1_4 ...
5
votes
4answers
502 views

Repeated function structure

How can I refactor this code? I know it's repetitive but I'm not sure how to fix it. $(function() { $('#category-1-button a').bind('click', function() { $(this).css({opacity:'1'}); ...
6
votes
2answers
390 views

Simple menu with sub-levels

The following works as intended, however is there a more concise way to write this script without changing it too much? It's a simple menu with sub-levels which have a plus/minus icon when each li ...
5
votes
1answer
151 views

How can I improve/optimize my jQuery PlugIn ?

I have just created my first jQuery plugin. I am looking to suggestions on how to improve it, leading to a code optimization. The plugin is working totally fine, but I think there's room for ...
2
votes
2answers
157 views

Simplify JQuery script

I've created a JQuery script to help illustrate a few points for my teaching class, but I have having trouble slimming it down. $(document).ready(function() { var red = $(".small-box"); var ...
3
votes
2answers
45 views

Optimize jQuery plugin according to DRY-principle

According to the DRY-principle, any ideas how to write this a bit shorter? jQuery.konami = function(fn, code) { // ↑ ↑ ↓ ↓ ← → ← → B A code = code || [38, 38, 40, 40, 37, 39, 37, 39, 66, 65]; ...
3
votes
3answers
423 views

Highlight input if empty

This snippets works, but I think it can be optimized: /* highlight input, if it is empty */ $(function() { var highlight_if_no_val=function () { $(this).toggleClass('highlight-input', ...
2
votes
1answer
200 views

How can I simplify/improve this jQuery code & comply with best practices

I'm trying to improve the quality/efficiency of my coding (having only been learning jQuery for a couple of months). I have a function which loops through all $('.loop-bar')'s and applies a jQueryUI ...
1
vote
3answers
1k views

Randomize a jQuery object list

Well this was a simplest code competition at my work. I tried a couple things, they accepted but none of them is I wanted. Because both are always giving same result. I tried to randomize like this ...
1
vote
0answers
125 views

Jquery Custom Tooltip Plugin

I am currently working with my first plugin(ie..tooltip plugin)and here is my code: (function ($) { $.fn.Tipify = function (options) { /*setup default settings*/ var defaults ...
0
votes
1answer
479 views

refactor javascript - show and hide fields based on current selection

I need help refactoring the javascript. http://jsfiddle.net/BDLYP/ I was able to hide and show fields, but I know this can be improved upon. If #state is empty, hide #high-schools and ...
0
votes
4answers
333 views

Optimizing some jquery, remove class adding a class?

I have a navigation, with a sprite that changes based on the class. In my jquery, I'm clearing out he classes so it will just have .nav then addClass the right class based on the click. It works but ...
5
votes
1answer
234 views

Movable Square-Div with Web Sockets, ws module, Node.js, and jQueryUI [closed]

I'm trying to make a simple little program in Node to use as a code base from with to program my whole web app. However, it isn't exactly working as planned because I'm stuck. I wanted it so that ...
4
votes
1answer
468 views

Need a review of a jQuery plugin that conditionally displays elements based on form values [UPDATE]

I've just released a jQuery plugin that conditionally displays elements based on form values. I would appreciate any suggestions on how to improve both the code and its usefulness. ADDED CODE UPDATES ...
4
votes
2answers
994 views

Javascript Code/Class Structure

In my never ending quest to write better code, I'm revisiting overall JS code structure and class patterns. I think I've come to a structure that I'm happy with, but would love to get some feedback ...
2
votes
2answers
628 views

Wrapper for jquery ajax to ensure redirects occur on clientside

Recently I had the need to make some ajax calls within a MVC 3.0 with Razor and jQuery application. After a bit of trial and error and refactoring it was discovered that a number of different needs ...
-2
votes
1answer
150 views

Accordion code needs feedback [closed]

I have come across this code that I have tried to add to but I am afraid that I have made of mess of it. I am not very experienced with Jquery or web design and I need help finding what I have done ...
4
votes
3answers
137 views

Code Tidying up?

What is the best way to tidy up JavaScript code I have written. It seems very long winded, any suggestions to shorten it? note: I'm running it on Wordpress which runs jQuery in nonconflict mode. ...
3
votes
2answers
191 views

jQuery Object Oriented Plugin

Update: Great answers up to now, but I would still love to have a bit of review about possibility of variable caching and the filter I'm using for rows and page sets! After seeing a lot of ...
2
votes
4answers
553 views

jQuery, Different way to write multiple click functions?

I have the following .click() functions. $('.tab').click(function(){ $('.tab').removeClass('activeTab'); $(this).addClass('activeTab'); }); $('.edit').click(function(){ $(this).hide(); ...
2
votes
2answers
577 views

Optimize coloring book built with Raphaël and jQuery

I've been building a coloring book for kids: http://coloringbook.core.ba.lightburncloud.com/ It's got to work on an iPad, so I decided to try out Raphaël JS. I want to try and make this as efficient ...
2
votes
2answers
8k views

jQuery marquee , without flickering, less memory consumption , and no plugin

I have tried jQuery to create an alternative of marquee. And got no success; it flickers , it does not stop on hover. I edited and edited again...and finaly came out with a jQuery + javascript mess. ...
2
votes
1answer
1k views

jQuery function to link nested checkboxes

$.fn.linkNestedCheckboxes = function () { var childCheckboxes = $(this).find('input[type=checkbox] ~ ul li input[type=checkbox]'); childCheckboxes.change(function () { var checked = ...
1
vote
2answers
118 views

jquery/javascript - refactoring multiple .on() events

My app has a feature that when you click the "new data" button, HTML is loaded to the page via ajax. Because I am using ajax, all events I want to add has to be bound using the on() method. There ...
1
vote
1answer
173 views

JQuery Multi-Functional Event Delegate

So, I'm pretty new to JQuery, maybe a week's worth of experience, but I'm having a lot of fun so far. One of the things I thought I would give a shot is attempting to implement a custom CMS for my ...
1
vote
1answer
104 views

how can i write this shorter

// hover on svg polygons $('#p1b7').hover(function() { $('.apla h4').stop(true, true).text("piętro i : mieszkanie nr. 7, 4 pokoje"); }, function () { $('.apla h4').stop(true, true).text("piętro ...
1
vote
1answer
110 views

First go at my own form validation, and suggestions?

Well I just finished my first go at my own form validation (I always used validate plugin) for simple front end. It's definitely small potatoes as it's only meant for a form with 4 fields; 3 required ...