Saturday, 31 May 2014

Javascript replace

var x="<div><a onclick='hello()' href='#' </a></div>";
var start = x.indexOf('<a');
var end = x.indexOf('</a>')+4 ;
var final = x.slice (start,end) ;
x = x.replace(final,'hello');