i am having some problems here. Here is my code:
$(document).ready(function() {
$("#button").click(function(){
alert("hello");
var a = $("textarea").val();
var b = $("#search").val();
var c = $("textarea").length;
var d = $("#search").length;
var array = [];
var st = "";
for(var e=0;e<c;e++)
{
for (var f=0;f<d;f++)
{
if(a[e+f] === b[f])
{
alert(a[e+f]);
array.push(a[e+f]);
if (array.length === d)
{
for(var g in array)
{
st += array[g];
}
a.substr(e,e+f).replaceWith("vinh");
break;
}
}
else
{
break;
}
}
}
});
});
The bad news is that when the document is ready, there isn't any $("#button") at first. Only after i trigger a code that append button to html but it is too late, the button won't run. Can anyone solve this ?. Many thanks to your help