How to get HTML element from event in jquery?

In a jQuery function I am getting event on form’s element click event. Now I want to get its html. How it is possible ? For Example: function(event, ID, fileObj, response, data) { alert( $( ); // output: [object Object] alert( ); // output: [object HTMLInputElement] alert( $( ); // output: (nothing) } I […]

How to remove nth character from the string?

I have a string with certain amount of commas. I want to find index of 5-th comma and then splice it. How can I do it? Like this string: “This, is, my, javascript, string, to, present” Turn into this: “This, is, my, javascript, string to, present”

how can you open a new page using javascript

i have code that sets window.location.href = [someurl] but i want to have it open up in a new tab. Is there anyway to have the above code include target=”_blank” from javascript?

What is causing I.E. to not validate (jquery) when other browsers do

I have a form using jQuery 1.7 and jQuery validation 1.9 (latest each at the time of this post), which works on firefox / chrome / safari, but only partly works on I.E. (8.0 at least, haven’t tested other versions) — not sure what the deal is. There’s an example here: if you click […]

Get multiple character positions in array?

I want to get position of dots and commas in an array. w.wer,ads, should give something like: [0] > 1 [1] > 5 [2] > 9 How can this be done with javascript?

How do I prevent execution of code in a “for” loop?

I have a loop: for (var language in locales) { if(language == ‘en’) //go on to next language and do not do code below I wish to prevent code inside the for from executing in certain conditions. I’ve tried break; but this stops the entire loop from continuing on to the next language. How can […]

JavaScript rounding numbers

I know that I can round a number like this var number = 1.3; Math.round(number); and the result I’m given is 1. But how can I round a number to the next highest whole number? So round 1.3 to 2 instead of 1?

Why my Regex let me write “,” (Comma)?

I have a JavaScript regex function code above: function AcceptDigits(objtextbox) { var exp = /[^\d{1,3}]/g; objtextbox.value = objtextbox.value.replace(exp, ”); }; Always that I write a any special character the function remove this character for Example: I write 45656654@ and this function clean the “@” like that 45656654. My problem The problem is that when I […]

Javascript: Optimizing details for Critical/Highly Processed Javascript code

I’ve been looking through a lot of Javascript Optimizing and most of them talk about string concatenation and a few other big ones found here, but I figured there had to be more details that you can optimize for when speed is critical and the processing of those pieces of code is very high. Say […]

Open new window on center of screen with this javascript?

My experience with javascript is extraordinarily limited. I would like to have the new window open up in the center of the screen. <script type=”text/javascript”> function fbs_click() { var twtTitle = document.title; var twtUrl = location.href; var maxLength = 140 – (twtUrl.length + 1); if (twtTitle.length > maxLength) { twtTitle = twtTitle.substr(0, (maxLength – 3)) […]