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
https://forums.phpfreaks.com/topic/146893-highlighting-a-word-in-div/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.