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

learn more… | top users | synonyms

11
votes
1answer
643 views

Responsive/adaptive website code

I have all these functions that work together to create functionality on a page. Is the structure of these functions OK? Can I do anything to speed this up or make my code better? I'm not exactly ...
2
votes
2answers
154 views

is there a way to write this shorter

i need opinion, is there a way to write this shorter ...
4
votes
4answers
12k views

Different way of writing multiple click functions

I have the following .click() functions: ...
7
votes
4answers
547 views

Repeated function structure

How can I refactor this code? I know it's repetitive but I'm not sure how to fix it. ...
1
vote
3answers
4k 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 ...
10
votes
2answers
165 views

Namespacing jQuery/jQueryUi into markup that I don't control

I have a project that I've been trying to get just right for the past three months and it's still not quite there yet. I'm injecting some jQuery and jQueryUI code into pages that I have no control ...
10
votes
3answers
218 views

MS Excel type of grid in jQuery

I have created a MS Excel type of grid in jQuery. I want to learn best practices and I need your comments for more optimized code. Please review the code and offer your suggestions. Demo jQuery: ...
7
votes
2answers
628 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 ...
6
votes
1answer
230 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
163 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. ...
3
votes
2answers
71 views

Optimize jQuery plugin according to DRY-principle

According to the DRY-principle, any ideas how to write this a bit shorter? ...
3
votes
3answers
717 views

Highlight input if empty

This snippets works, but I think it can be optimized: ...
2
votes
1answer
73 views

Adding, deleting elements as per autocomplete results - updated

I am working on a Python/Django project which has turned into a JavaScript/jQuery project due to the amount of asynchronous functionality that I thought to add. There is a JavaScript file which is ...
2
votes
2answers
154 views

Is this JavaScript/jQuery methodology good?

I am seeking critique on what has become my normal methodology of writing JavaScript code. I have become heavily reliant on the jQuery library, but I think this has helped me learn the native language ...
2
votes
1answer
295 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
0answers
67 views

Adding, deleting elements as per autocomplete results

I am working on a bookmarker project for replacing storage of bookmarks in webbrowser. It will be storing bookmarks as per categories in a database. I have written some jQuery for the WIP search page. ...
0
votes
1answer
1k 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
902 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
5k views

Handling Hover Events on a Touch Screen

A website I have designed uses a nav menu that shows submenus on :hover. The initial site did not use any responsive design: it targeted only the desktop environment. I am now using responsive-design ...
5
votes
2answers
1k 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 ...
20
votes
8answers
5k views

Better way to code these deeply nested / multiple if/else statements

I have coded this mess of JavaScript and a bit of jQuery. Everything here works perfect as intended, however it is a real mess. What would be the best way to clean this up with best practices and ...
6
votes
1answer
775 views

Plugin that conditionally displays elements based on form values

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. Here's the demo ...
2
votes
2answers
4k 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 ...
3
votes
1answer
37 views

Set up event on class and initialize state [closed]

Very similar to this question, I'm curious about common patterns/best practices for handling events in coffeescript classes, particularly when you also need to call the event handlers immediately to ...
2
votes
1answer
2k views
-3
votes
1answer
163 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 ...
11
votes
3answers
1k views

Ultimate Tic-Tac-Toe Challenge

This is my attempt at the Ultimate Tic-Tac-Toe code challenge. It uses jQuery to build out the game grid and find the states of all the "buttons" (actually ...
10
votes
2answers
106 views

Member list reveals member information on click (#1)

What I'm doing? I'm creating a member-list where initially only the names are visible. Clicking the names reveals the member information. This is done with jQuery by adding/removing classes. I left ...
6
votes
2answers
117 views

Simplifying this form validation script

Can anyone please help me to simplify this form validation script? It works great but I was just wondering if I can get some help to make it simpler. Your opinion on the approach I used below is ...
4
votes
1answer
75 views

Personal project for managing my bookmarks

I am working on a personal project for managing my bookmarks, which is basically a web page to manage my bookmarks by categories. Managing here means everything - adding, viewing, updating, searching ...
4
votes
2answers
65 views

Initializing events on class

I wrote a simple class that substitutes all file inputs in an HTML for a more complex template and set some actions on it. The code is rather small, but I'm not used to write JavaScript. I wonder if ...
4
votes
2answers
59 views

Page loader function

This is the function which I wrote and am currently using in my project. I want to know if there is a better way to write it: ...
4
votes
1answer
64 views

jquery script for inserting and deleting text

Unfortunately I get 3 warnings at jslint. Could someone please help? I already tried a lot, but didn't get it yet. Here's a jsfiddle: http://jsfiddle.net/KYjF9/21/ JSlint options: ...
4
votes
2answers
169 views

Simplifying this form validation script - version 2

A week ago, I have asked how to simplify a form validation. From the answers, the code now is improved. Can anyone please share their opinion on the approach used below and advise me if there is a ...
4
votes
3answers
256 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
1answer
203 views

Update database, reload page then show a success message

I have spent a long time trying to find a way to do the following: Update a MySQL database with AJAX Reload the Page to show changes Show a success message I think I have finally found a way! ...
3
votes
1answer
89 views

How could I have approached this responsive image gallery differently?

This gallery uses the Orbit gallery from the Foundation framework (version 3). I've set it up so that on smaller screens it appears as an accordion. It works just fine, but is there a more concise ...
3
votes
1answer
104 views

Best practice for generating jQuery dynamical content

I am new user of CodeIgniter and I am trying to build an application that there are lots of jQuery dynamical content. Below I provide a code that I am using in order to be precise. The code below is ...
3
votes
1answer
103 views

A package for the DOM

Concerned with the length of this and the organization. Looking to organize it better if possible. If anyone knows the jQuery equivalent of these methods I would like to put them in the comments. ...
3
votes
1answer
144 views

jQuery Newbie possible ways of refining navigation code

I have navigation items that are created dynamically with PHP. I wrote the jQuery below because I need to add individual classes and fire them individually, so my code below works, but I want a way of ...
3
votes
2answers
531 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
1answer
134 views

JavaScript eBay Listing Generator

I'm still pretty new at JS and, frankly, this is probably a little above my skill level. But here's my attempt at a script that will take user input and produce a custom interactive eBay listing. ...
2
votes
1answer
51 views

jQuery grid-system - handing different row widths

I made a function in jQuery for my home-made grid system. When a row has too many columns in it, it removes the HTML code from ...
2
votes
0answers
66 views

Insert and Delete (a list of specified) characters/words in headline [duplicate]

I'm very new to JavaScript and I'd appreciate some help. Here's a jsfiddle: http://jsfiddle.net/KYjF9/3/ I'm trying to make that code more elegant and also valid at http://www.jslint.com/ (browser ...
2
votes
2answers
92 views

Find number matching range

I have code that checks the range of a value and sets a variable accordingly. ...
2
votes
1answer
133 views

Two click functions doing the same thing with difference the selector

I have the following jQuery click functions: ...
2
votes
2answers
490 views

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 ...
2
votes
2answers
785 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
12k 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. ...
1
vote
5answers
339 views

Simple image rotation script

I am writing a simple image rotation script. Users press either the prev or next button to view the previous or next images. It works well, but the code looks over the top. Is there a way I can reduce ...