Searching for a string in a web page
Instead of wrapping your code in $(document).ready(function(){, you should put the &lt;script&gt; tag at the bottom of file ( right before closing &lt;/body&gt; ), then you script will get executed right after the DOM is ready.
Do not use innerHTML for working with DOM
Stop selecting DOM element each time you want to do something with it. It is an expensive operation. Instead get the element once and store in a variable.
Your trim() method initializes obj twice.
Do not use .length in loops. Instead assign value to variable and reuse it.


And, honestly, get rid of jQuery. You are not using for anything special. Only simple DOM manipulations.