Dynamic search of words in jquery
Random words are appended on different positions of the body, (function is continuously run by settimeout())
$('body').append('<span class="box" style="position:absolute;font-weight:bold;color:#'+
color + ';top:'+ top +'px;left:'+left+'px;">'+ randomWords +'</span>');
$("input").keyup(function(){
var textBoxValue = $( this ).val();
//input value is comparing with the elements in the body
$("body .box").each(function() {
if($(this).text()==textBoxValue){
$(this).remove();
scoreupdate();
});
});
Here instead of doing this is there any way to dynamically check each word and when typing each letter the correspondence letter should highlight and when the whole word matches the score should update.
$('body').append('<span class="box" style="position:absolute;font-weight:bold;color:#'+
color + ';top:'+ top +'px;left:'+left+'px;">'+ randomWords +'</span>');
$("input").keyup(function(){
var textBoxValue = $( this ).val();
//input value is comparing with the elements in the body
$("body .box").each(function() {
if($(this).text()==textBoxValue){
$(this).remove();
scoreupdate();
});
});
Here instead of doing this is there any way to dynamically check each word and when typing each letter the correspondence letter should highlight and when the whole word matches the score should update.
Комментарии
Отправить комментарий