Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Thursday, October 10, 2013

Solved - mouseover not working on dynamically generated ul li

$(".CLASS_NAME").on("mouseover", "li", function() {
   alert('now the mouseover will work');
});
 
NOTE : replace CLASS_NAME with your selector. 
 
Read the DOCS! http://api.jquery.com/on/ 

Friday, September 13, 2013

How to replace multiple occurence in a string in javascript

Here is the code :
str = str.replace(/abc/g, '');
 
or you can use this one :
var find = 'abcxyz';
var re = new RegExp(find, 'g');
str = str.replace(re, ''); 

or

function replaceAll(find, replace, str) {
  return str.replace(new RegExp(find, 'g'), replace);
}
 
call the function :  
replaceAll(find, replace, str);