jquery

Using an ajax reload with a Wordpress plugin

I am making a Wordpress plugin that provides updates in the widget section of the page - everything works fine. The one thing that doesn't is the ajax callback (using load with jquery). It appears that Wordpress is blocking direct access to the php file that I am trying to load (it is in /wp-content/plugins/myplugin). How should I be ...

Finding the index of an element within a live function

I'm creating new < li > elements with a live() click function, but jquery won't tell me the index of newly created elements. Here's the code: $esl = $('.dynamicLink'); $esl.live('click',function(){ var dynamicIndex = $esl.index(this); alert(dynamicIndex); }); Whenever I click the dynamicLink, it returns "-1...

Function "remembers" value problem

This is a simplified partial version of my code to demonstrate the issue: function testFunc(){ var randomNum = Math.floor( Math.random() * 100 ); if( !flag ){ addEvents(); flag = true; }; function checkNumber(){ alert(randomNum) } function addEvents(){ $("#someElement").click(function(e){ chec...

Javascript/Jquery date picker

I'm looking for a simple to integrate date picker object, which would be triggered when someone focused on a particular textbox. When a user clicked or focused on a textbox, the date picker interface should pop up, with the current date on it, and the user could easily select the date. When done, the textbox should have the date in the f...

How to select all text in a textbox and copy it to clipboard using JavaScript/jQuery?

I have a textbox with an 'Add to clipboard' button next to it. Whenever the copy to clipboard button is pressed, I want the contents of the clipboard to get copied to the clipboard, and work in a cross browser way across Internet Explorer, Firefox, Chrome, Opera, etc. I can use jQuery or plain JavaScript. How can this be done? ...

How to get the text of the selected option of a select using jquery?

If I have this select: <select id="days"> <option value="0">Today</option> <option value="1">Yesterday</option> <option value="7">Last week</option> </select> and someone selects the 3rd option 'last week', I can get the value of last week (which is 7), using $("#days").val(), but how can I get the va...

Key Pad driven web UI

I have a fancy web page with lots on JQuery included. Currently i am struggling to find a solution to make it keypad driven. I want the buttons on the page to be clicked when the user press some key combination (e.q. save should happen if the user click on Ctl+S button on the keypad. Does anyone have experience doing something similar? ...

Interesting jQuery Animations

I have been playing around with jQuery for a bit now, and am really curious how far someone would be able to take this. Has anyone seen (or written) some jQuery code that did some memorable animation? Something that stood out. I am quite interested in seeing some ideas. Please post your experiences. Thanks. ...

contenteditable change events

I want to run a function when a user edits a contenteditable div. What's the equivalent of an onchange event? Thanks. I'm using jquery so any solutions that uses jquery is preferred. Thanks! ...

Why do some sites use jquery with a $j instead of just a $?

I generally use this in jquery $(document).ready(function() { //stuff } I was just on a site that heavily uses jquery and they call it using $j(document).ready(function() { //stuff } On this site they start almost everything out with a j... function PostComment(form) { form = $j(form); $j('#CommentSubmitButton').h...

How do you add an event to a jQuery element that was just added?

Suppose you want to dynamically add to a HTML menu, where the menu HTML will look like-so: <ul> <li><a href="#">item-1</a> <li><a href="#">item-2</a> </ul> And each element has a "click" event bound to it by. How does one create this dynamically with jQuery? What'd I'd like is the equivalent of the following (with hypothetical menu_...

JSON and jQuery help please {question edited} :)

Thought it would be easier if I redid the question, I hope. Thanks again for all your help, and I have this thing working mostly. What I dont get is, if I have the file on my desktop, drag it into a browser then it works. If I upload the same file to my website and visit it, it displays nothing in firefox. Last night it worked in saf...

Limiting input to a set of characters while also displaying those characters

I have seen in a few "username" fields where you type in a username, and below it, in something like a span, it will append it to a url. A lot like what is happening as I type this in StackOverflow at the bottom. I would like to show only allowed characters from a list, ignore any input of characters not in that list. I am really new ...

jquery: $(this) confusion

I have 3 buttons. I'm trying to get it so that when one is clicked it gets a class of 'this-button' and the class is removed from others. <button id="button1">Button1</button> <button id="button2">Button2</button> <button id="button3">Button3</button> So here's my simple event function: $('button').live("click", function (){ ...

javascript templating engine that maintains focus on textboxes etc?

So I know there is a few templating engines out there, but I thought I'd ask for someones experience and reccomendation on one that can do what I'm after. I'd previously made an (intranet) web app that used asp.net editable listviews to take input and used an update panel to make it persist the data regularly (save) This worked ok but...

Providing Arabic language support to an application

I have a chat application . I want to give Arabic language support to my application. Is there any way to change language when a user selects his language from a select box? The User requires to Write in Arabic in his text area. ...

How to destroy a DOM element with jQuery?

Suppose the jQuery object is $target. ...

Can a DOM element have an ID that contains a space?

And if so, how do you select on with jQuery? I.e., $("#a b") looks for all <b> nodes within the node with id=a. ...

How to prevent window from scrolling up on jQuery slideToggle()?

I'm using jQuery to dynamically add two divs on page load. It all works great, except, when I click the "Advanced Options" link in the first dynamically loaded div - it performs it's correct behavior (sliding the second dynamic div), BUT it resets the scroll of the window back to the top. I attempted to focus on the first input element...

php in jquery code possible?

I have the below jquery function $(function(){ $("select#rooms").change(function(){ $.getJSON("/admin/select.php",{id: $(this).val(), ajax: 'true'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</...