I don’t understand why livequery doesn’t bind the event, but I have to use .click. This is just an example, which might also use the .click(), but in the real code I’m forced to use livequery. Does anyone know why livequery isn’t working? Answer I added a random id to the last comment,…
Tag: jquery
jQuery UI Autocomplete
I am using jQuery UI’s autocomplete plugin and everything is well and good except for that fact that when a user clicks the value they want the function I have assigned to the “select:” method fires before the value of the field is changed. So if I type “Foo” in the input field, …
What is the purpose of backbone.js?
I tried to understand the utility of backbone.js from its site http://documentcloud.github.com/backbone, but I still couldn’t figure out much. Can anybody help me by explaining how it works and how could it be helpful in writing better JavaScript? Answer Backbone.js is basically an uber-light framework …
Max characters in textarea with jquery
I have the following code, and I’m kind of stuck on what to do next. The idea is when you enter text into a text area a counter tells you how many characters you have left. Once you get to the max characters I want to stop allowing characters to be entered, or delete all the characters that were entered
Is it possible to change the value of the function parameter?
I have one function with two parameters, for example function (a,b). I want to within the function, take the value of b, and replace that with c. I was thinking of something like $(b).replaceWith(c), but it didn’t work out. I know I can create a new variable within the function with the new value, but i…
Using the jQuery each() function to loop through classname elements
I am trying to use jQuery to loop through a list of elements that have the same classname & extract their values. I have this.. I was reading up on the each() function though got confused how to use it properly in this instance. Answer and if you wanted to get its index in the collection: Reference: .each…
How to find the 2nd closest ancestor in jQuery?
My DOM looks something like this: When the used clicks on ‘Edit’, I want to change the outer <li> to <li class=”selected>. I tried something like this, but this is not working: Any help is appreciated. Answer Go up a parent: It wasn’t working because closest starts with the…
How to load images dynamically (or lazily) when users scrolls them into view
I’ve noticed this in numerous “modern” websites (e.g. facebook and google image search) where the images below the fold load only when user scrolls down the page enough to bring them inside the visible viewport region (upon view source, the page shows X number of <img> tags but they ar…
How to use simulate the action of clicking button with jQuery or JavaScript?
I need to use JavaScript to simulate the action of clicking buttons. How do I achieve it? Can I achieve it with jQuery? Answer Yes, you can do it with jquery. Use trigger function. Here documentation. Here is sample:
Regular expression [Any number]
I need to test for “[any number]” in a string in javascript. how would i match it? Oh, “[” and “]” also need to be matched. so string like “[1]” or “[12345]” is a match. Non match: “[23432” or “1]” So for example: I need to re…