Jump to content

highlighting a word in div


jijodasgupta

Recommended Posts

hey guys...i hav a code tht searches a word from twitter and displays all messages tht contain tht word....

<script type="text/javascript"> 
    $(document).ready(function(){
        $('form#search').bind("submit", function(e){
            e.preventDefault();
            $('#content').html('');
            
            var query = urlencode($('input[name="searchTerm"]').val()); //what to search for
            var rpp = 20; //number of tweets to retrieve out
            
            $.getJSON('http://search.twitter.com/search.json?callback=?&q='+query+'&rpp='+rpp, function(data){
                 $.each(data.results, function(i, item){
                    console.log(item);
                     var newDiv = '<p><a href="http://www.twitter.com/'+item.from_user+'">'+item.from_user+'</a> - '+item.text+'</p>';
                     $('#content').append(newDiv);
                 });
             });
        })
        
        function urlencode(str) {
            return escape(str).replace(/\+/g,'%2B').replace(/%20/g, '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
        }        
    })
    </script> 
/code]

 

i puttin the outputs into a <div>...

my problem is.....i want to highlight the searched word in the div...

how do i do tht????

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.