0

I have been searching for days now.

I have some random numbers that are generated automatically with crunch function on 3 minute interval:

setInterval(crunch, 180000);

then I can nicely highlight the return random numbers with mark.js:

$(function() {
        var mark = function() {
            // Read the keyword
            var keyword = $("input[name='keyword']").val();
            var keyword2 = $("input[name='keyword2']").val();
            // Remove previous marked elements and mark
            // the new keyword inside the context
            $(".context").unmark({
                done: function() {
                    $(".context").mark(keyword).mark(keyword2, {
                        className: 'secondary'
                    });
                }
            });
        };
        $("input[name^='keyword']").on("input", mark);
    });

My problem is when the second lot of new numbers are generated the highlight goes away - please can you kindly share a way how I can make them stay highlighted forever?

Here is my working fiddle on a 3 min interval:

https://jsfiddle.net/heybubbles/eztgy7j9/12/

min: 1 max: 100 results: 100

I tend to search for the highlighted number after generation not sure how to make it search on generation apologies.

Many thanks in advance!

1 Answers1

0

if you change the keyword after the re-generating numbers it will re-highlight it. Don't appear to be a way to trigger mark manually and you have the change the input for it to re trigger, rather than use marksjs why not just do something like this

mark.js trigger event from selection

Patrick Hume
  • 2,064
  • 1
  • 3
  • 11
  • thanks Patrick, I have been playing around with this for a few days not any closer to getting it to work, as mentioned I would like to select a number or input it and that choosen number will be hightlighted when it appears in the forever changing random results. – heybubbles Jul 21 '22 at 02:33
  • I added the code snippet you kindly pointed me too and added this. ```
    ```
    – heybubbles Jul 21 '22 at 02:36
  • please can you kindly share a bin or pen of my example otherwise this should not be considered as a correct answer as the result is static not dynamic. thanks in advance! – heybubbles Jul 21 '22 at 02:38
  • sorry will do ASAP I am away at the moment so will do as soon as i can – Patrick Hume Jul 21 '22 at 10:36
  • Hey just one other thing that has been puzzling me... please can you make the numbers align nicely in columns and rows. I guess if you can do that I will create another overflow and assign it to you? many thanks in advance Patrick! – heybubbles Jul 21 '22 at 15:04
  • No worries about the number formatting I was able to figure that out - alignment is good for me, just a working example of the main question would be greatly appreciated Patrik! cheers Bubs – heybubbles Jul 24 '22 at 14:56
  • sorry for the late reply, here is a working example that will re highlight when you click generate every time https://jsfiddle.net/PatrickHume/1hn05jox/2/, i hope this helps – Patrick Hume Jul 27 '22 at 21:44
  • Awesome Patrick. really awesome. thanks mate! – heybubbles Aug 04 '22 at 18:43
  • np glad i was able to help :) – Patrick Hume Aug 04 '22 at 19:26