Skip to content
Advertisement

Tag: jquery

How to set DOM element as first child?

I have an element E and I’m appending some elements to it. All of a sudden, I find out that the next element to append should be the first child of E. What’s the trick, how to do it? Method unshift doesn’t work because E is an object, not array. Long way would be to iterate through E’s children and

How to delay the .keyup() handler until the user stops typing?

I’ve got a search field. Right now it searches for every keyup. So if someone types “Windows”, it will make a search with AJAX for every keyup: “W”, “Wi”, “Win”, “Wind”, “Windo”, “Window”, “Windows”. I want to have a delay, so it only searches when the user stops typing for 200 ms. There is no option for this in the

How do I get just the visible text with jQuery (or Javascript)?

I have website that converts Japanese Kanji into Romaji (roman letters): and the output shows and hides with CSS what the user needs to see depending on their input criteria. For example: <div id=”output”><span class=”roman”>watashi</span> <span class=”english”>I</span></div> The interface allows the user to flip between and output of watashi or I depending on what they want to see. The CSS

Single quotes in string with jQuery ajax

I have run into a problem where the user enters data and if there are single quotes at all, the script errors out. What’s the best way to handle single quotes that users enter so it doesn’t interfere with the jquery/javascript? UPDATE: I’m sending it through ajax to a database. here is the data parameter for a json ajax call.

How can I remove an attribute with jQuery?

I can’t seem to get removeAttr to work, I’m using the example I saw on the jQuery site. Basically onclick I add the attribute to disable a field (which works just fine) but when the user clicks again it should enable the field in question. I used alerts to make sure the else block is being fired, so I know

How to get a DOM Element from a jQuery selector?

I’m having an impossibly hard time finding out to get the actual DOMElement from a jQuery selector. Sample Code: and in another piece of code I’m trying to determine the checked value of the checkbox. And please, I do not want to do: That gets me around the checkbox, but other times I’ve needed the real DOMElement. Answer You can

e.which ENTER key enabled only if input field focus

I am using a e.which of jquery for running a function on press of ENTER, but I want this function to be called only if the particular input field is focused (where the cursor is blinking). My current jquery function. I want that $(“#search”).click(); to be called only if the #search_text is focused or has some input, because I have

Advertisement