Tagged Questions
4
votes
2answers
91 views
jQuery Dropdown Navigation
I've written some jQuery code that works, but I'm a novice in jQuery and I want to know how to improve my code if possible.
I know I have 3 near identical blocks of code. If I create a function, the ...
8
votes
1answer
2k views
Writing better code for validating a credit card
I recently created an extension which detects the type of credit card based on the numbers entered in and formats it. I am using Luhn Algorithm for validating credit card numbers and I am using jQuery ...
1
vote
0answers
146 views
Checkbox processes in jQuery
I was wondering if anyone would mind looking over my JSFiddle and letting me know if this is best practice for the operation.
I am looking at it and it works but it seems very verbose. The code ...
5
votes
3answers
67 views
DRYing out a basic image slider
I built a very basic image slider, but I'm still having trouble refactoring.
I caught myself reusing same code for clicking the previous/next buttons, selecting a slider dot, and the automated ...
2
votes
3answers
89 views
Inserting buttons inside a div
I'm trying to put lots of buttons inside a div with a bunch of little windows that make content change in a neighbor div, but I’m quite new to jQuery and I'm sure that this code can be much simpler.
...
5
votes
1answer
41 views
Breaking up a navigation menu
This code works as I intended, but I am definitely a JS noob (C++ background), so I'm not sure if this is the best way to do it (for example using .each instead of ...
0
votes
1answer
42 views
Getting data from the server via JSON callback and parsing the data to HTML
I'm pretty new to web development with JS and was wondering if anyone can tell me how I can improve my code. I just feel like when it comes to maintainability my code would be very difficult to ...
0
votes
1answer
39 views
How can I refactor to avoid problems with function expressions (hoisting)?
The folllowing is a series of functions to ensure that various elements on a page line up no matter what window size or when the window is resized. However I'm not sure my code is very concise as I am ...
2
votes
0answers
142 views
jQuery animate opacity, fade, & slide up page load effect
This is the first time I've actually made my own jQuery script from scratch, because I couldn't find exactly what I was looking for. My code works how I want it to, although I don't know if I did it ...
3
votes
2answers
57 views
Method for sorting numbers
I am new to jQuery and I want to know if there is a more efficient way to achieve this.
I have an input with numbers 1, 2, 3, 4 and I want to change the order of this number dynamically according to ...
0
votes
1answer
119 views
Saving to database
I want to insert and edit values on the same button click. The code is working fine and I am using the same code for both insertion and deletion.
...
2
votes
2answers
506 views
Query, populate, show, hide data
I have created code to show/hide data from a DB. It works, but as I am new to jQuery, I would like to know if this is a good way.
HTML:
...
2
votes
1answer
93 views
jQuery plugin authoring: Vertical Center example
I am fairly new at writing jQuery plugins. Moreover, I am a huge fan of best practice.
I have written a plugin which centers an element inside its parent. I would love some feedback on how I could ...
5
votes
4answers
250 views
Providing one-time calculations to frequently used methods
I'm new to JS/jQuery and wrote some JavaScript/jQuery lines to create a "pulsating" object.
I get the "pulse" effect by increasing/resizing the object and then bringing it back to its original state ...
5
votes
1answer
38 views
JavaScript scrippits
I was doing writing some various things in JavaScript and ending up writing 2 scripts that proved useful in quite a lot of my other programs and I was wondering if there was anything that I could do ...
4
votes
2answers
62 views
Major code bloat reduction with jQuery
Basically I want some help in reducing the bloat of this code. I am new to JavaScript so this represents an attempt at learning jQuery by doing. All of this code works as I want it to, but it is not ...
3
votes
1answer
154 views
Menu Bar Animation Plugin
I'm fairly new to JS/jQuery (a few months), and I think it's time to start getting involved in the community. So I wrote a little plugin. Nothing revolutionary. Really, the project is to write a ...
5
votes
1answer
165 views
Load JSON file into model using Javascript / jQuery (deferred, asynchronous)
As a beginner I am always determined to improve myself. I've got written the following Code using jQuery that is working fine. However, I am sure that there are cleaner ways for achieving the same.
...
2
votes
1answer
2k views
Basic calculator in jQuery
I have been using HTML and CSS for a long time, and just starting to learn jQuery. I created a calculator by myself from research and trial and error. I would like someone to let me know what I'm ...
5
votes
1answer
210 views
Responsive jQuery restaurant menu system
I have a working restaurant menu system - as the user selects a menu it slides into view. The build is responsive, I've used the 'Debounced Resize() jQuery Plugin', however in implementing the ...
5
votes
1answer
164 views
Active Directory details page
Recently I have been making an MVC application with a fluid, responsive design in mind. One of the views has been to implement a fast responsive active directory details page. This is how I have ...
2
votes
1answer
50 views
jQuery tooltip optimization
This is my second jQuery script: a universal tooltip for my entire web page. It took me a couple of days to research and make it work.
Now, I need help from the experts to optimize my newbie code.
...
5
votes
3answers
170 views
jQuery Tab function
I have this script that I need to run a tab (jquery). Mainly I need to hide some div and add class (you sure have understood).
How should it be written in a more elegant and readable?
...
10
votes
1answer
136 views
Tabbed navigation to hide and show pages
I'm new to jQuery and trying to learn how to refactor my bloated code to make it nicer and better maintainable.
I have a tabbed navigation which I'm using jQuery to hide and show pages depending on ...
3
votes
1answer
111 views
Dynamically-loading interactive table
I've got a page on a website that shows a table, and upon clicking on a row in the table, it can dynamically load in more results. I am new to jQuery though.
index.php page:
...
10
votes
3answers
754 views
Clickable icon for expanding/collapsing content
The general idea of the code is that I have a + or - icon (".trigger") that is click-able ...
6
votes
2answers
223 views
Data attribute text() swap on hover
This is a very basic script. If the screen width is larger than say a tablet, and a portfolio link is hovered over, it will fade out the original text and replace it with the text held in the ...
6
votes
2answers
197 views
Applying timed functions recursively
I am relatively new to JavaScript/jQuery, and cobbled together a script. Essentially, the script sets individual timers on specific DOM elements, and then recursively applies timed functions to them. ...
3
votes
1answer
55 views
.get() for multiple unique files
I'm using jQuery's .get() method to load content from external HTML files into my main index file. I created 25 different functions, function ...
6
votes
2answers
81 views
Removeclass addclass multiple selectors optimization
I've written a function that works fine, but being new to jQuery, I'd like some reviews on writing this more cleanly. Anything advice would help; just trying to learn!
...
8
votes
3answers
102 views
Fail-proof AJAX
I'm working on a page using AJAX that will get an entire .php page when the navigation button is clicked. I have that set up and working right. But this is my first time using AJAX, so I'm not sure ...
5
votes
1answer
78 views
What are your opinions on these small scripts?
I am new to JavaScript, and I was wondering if anyone can share their opinions on what I have done below:
First of all, the following functions are all placed in a file called main.js and that file ...
3
votes
4answers
109 views
Coding upgrade (CSS3 x jQuery) tips
I'm just beginning web design, and I've come up with this code to scroll to a place in the same page.
I don't know if this can or should be improved much longer, so I'm asking for any tips that can ...
9
votes
2answers
97 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
1answer
74 views
Pass in parameters instead of multiple functions
I can't quite figure out the best way to approach this. I have two jQuery objects that both are used to set cookies. I then parse the JSON and set a cookie that is either the users height or the users ...
5
votes
1answer
87 views
Dynamic toggle system
I'm new to jQuery/JSON and I've build an dynamic toggle system. It work fine, but I'm not sure about my code and I want a better way of building this.
Could you please see my code and give ...
2
votes
1answer
513 views
Drop-down menu button highlighting and hiding
I'm learning JS/jQuery at the moment and have built the following standalone script but I feel that it can probably be improved in some ways?
For example - is there a better way of switching the ...
4
votes
1answer
406 views
Styling <select> dropdowns with jQuery
I am new to JavaScript, HTML and CSS, although not to programming.
I wanted to style 'select' dropdowns, so I wrote this:
What noob mistakes am I making? Is this a good or evil use of JS?
...
1
vote
0answers
526 views
Overriding sorter and matcher in Bootstrap Typeahead
In this code, I'm overriding the sorter and matcher for Twitter-Bootstrap's Typeahead functionality. The reason for the override is to allow state (technically Jurisdiction) abbreviations to be used ...
7
votes
2answers
151 views
jQuery-animated navigation menu
On the attached fiddle is what I hope will the be future UI for navigation on my own personal portfolio site. I was hoping you guys could critique the JavaScript I wrote to accomplish the most ...
1
vote
2answers
76 views
2-way carousel for iPad and tablet
I've just finished a program for a 2-way carousel. Meaning, if I click left or right, you are able to go up and down, depending on where you are. This is suppose to work for iPad or tablet only.
I ...
2
votes
1answer
72 views
jQuery to construct elements
I'm new to jQuery, and am using it to dynamically construct chunks of a page.
The created HTML is what I want, but I'm not sure if the way I'm generating it is sensible or idiomatic.
...
-1
votes
1answer
161 views
if / else if and animate issue [closed]
I am still new to coding, especially jQuery, and I was trying some effects for a website I am trying to make.
My code works perfectly for the first two buttons / pages, but when the third comes in, ...
2
votes
1answer
215 views
Minesweeper clone in jQuery
This was my first attempt at writing object-oriented JavaScript. It's a Minesweeper clone in jQuery. I thought I had done an ok job, but I've just received some feedback stating that it wasn't written ...
3
votes
1answer
78 views
Comment on this simple jQuery drag event
I would like some comments on my code and implementation for this simple piece of jQuery.
Basically it is 2 div boxes #side1 and #side2, in a container div called #frontimage, where #side2 can be ...
1
vote
1answer
217 views
My first responsive image slider
I have been doing some Code School classes on jQuery, and I needed a image slider for my site. Right now, there are only two responsive states, but that will most likely change (and/or become fluid ...
1
vote
1answer
648 views
JavaScript and jQuery check for image file and assign CSS
This is my first attempt at JavaScript, so I am looking to learn.
I have a website that has jQuery built in and I wanted to leverage that in the following way:
I want to get a number variable ...
1
vote
1answer
80 views
Improving jQuery slider
Problem:
Make a slider, located at the bottom of the page. The slider should be dynamically loaded only when an div(#slider) becomes visible on the screen. Images do not have to load all at once. Load ...
5
votes
2answers
165 views
Toggle script trouble
I have been working on a toggle script, but I find myself repeating my code. Is there a way of combining it all? I am new to jQuery, so forgive me for my beginner question.
HTML:
...