I’m trying to write a “suggestion search box” and I cannot find a solution that allows to highlight a substring with javascript keeping the original case. For example if I search for “ca” I search server side in a case insensitive mode and I have the following results: Calculator calendar ESCAPE I would like to view the search string in
Tag: javascript
How to trace Javascript events (Stack Trace )?
In any programming language, I can trace any function and know which function is called by other. But in Javascript , I don’t know how, since the code is not written by me and Firebug does not give this feature – as far as I know. An example : I want to display the function names of each function that
jQuery’s .click – pass parameters to user function
I am trying to call a function with parameters using jQuery’s .click, but I can’t get it to work. This is how I want it to work: $(‘.leadtoscore’).click(add_event(‘shot’)); which calls It works if I don’t use parameters, like this: But I need to be able to pass a parameter through to my add_event function. How can I do this specific
Select Element By CSS style (all with given style)
Is there a way to select all elements that have a given style using JavaScript? Eg, I want all absolutely positioned elements on a page. I would assume it is easier to find elements by style where the style is explicitly declared: the style is non-inherited (such as positioning) the style is not the default (as would be position:static). Am
How to silently hide “Image not found” icon when src source image is not found
Do you know how to hide the classic “Image not found” icon from a rendered HTML page when an image file is not found? Any working method using JavaScript/jQuery/CSS? Answer You can use the onerror event in JavaScript to act when an image fails to load: In jQuery (since you asked): Or for all images: You should use visibility: hidden
How can I share code between Node.js and the browser?
I am creating a small application with a JavaScript client (run in the browser) and a Node.js server, communicating using WebSocket. I would like to share code between the client and the server. I have only just started with Node.js and my knowledge of modern JavaScript is a little rusty, to say the least. So I am still getting my
Detect changes in the DOM
I want to execute a function when some div or input are added to the html. Is this possible? For example, a text input is added, then the function should be called. Answer 2015 update, new MutationObserver is supported by modern browsers: Chrome 18+, Firefox 14+, IE 11+, Safari 6+ If you need to support older ones, you may try
JavaScript – Get all but last item in array
This is my code: I want linkElementLink.href to grab everything but the last item in the array. Right now it is broken, and the item before it gets the second-to-last item. Answer Use pathname in preference to href to retrieve only the path part of the link. Otherwise you’ll get unexpected results if there is a ?query or #fragment suffix,
Accessing the content of other tabs in a browser
I am using Mozilla Firefox and I am trying to figure out a way to access the content of other tabs in the same window using JavaScript and the DOM (I am open to other techniques if exist). E.g., I want to run JavaScript code in tab1 which can find the title of some other tab. Basically I need this
why can’t i set window.onload in IE8?
I have the following function, which works fine in Firefox, but will do nothing in IE8 I want to open a webpage and immediately open the print dialogue. Answer If you have the hand on the page at url, place the call there. In the HTML, at the end of the BODY tag. Add a SCRIPT tag with your call