how to make image bright and how to change text color dynamically

by Developer 21. February 2010 07:33

There are some situations where you need to change the content display dynamically. Like, you have to change font color and background color of your text or you have to make image bright. You can do these things by applying styles dynamically through javascript.

 

Here I gave you a solution to fulfill such type of requirement by using jQuery functions. We are using jQuery mouseover() function to highlight text or image on your webpage whenever we place mouse on it.

 

Below is the code to make text or image highlight whenever we place mouse on it.

 

<html>
    <head>
        <title>highlight the text and image dynamically using jQuery</title>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
            $('#parent').mouseover(function() {
            $('#child1').css({
                    'background-color': 'green',
                    'font-weight': 'bold',
                    'color': 'red'
                });
             $('#child2').css({
                    'background-color': 'cyan',
                    'font-weight': 'bold',
                    'color': 'blue'
                });
               
                $('#img1').css({
                    'opacity':1.0                   
                });
            });

            $('#parent').mouseout(function() {
                $('#child1').css({
                    'background-color': 'white',
                    'font-weight': 'normal',
                    'color': 'black'
                });

                $('#child2').css({
                    'background-color': 'white',
                    'font-weight': 'normal',
                    'color': 'black'
                });

                $('#img1').css({
                    'opacity': 0.4
                });              
            });
           
            });   
        </script>
    </head>
    <body>
        <div id="parent">
            <div id="child1">this text from first child</div>
            <div id="child2">this text from second child</div>
             <img src="img1.jpg" id="img1" style="opacity:0.4" />
        </div>       
    </body>
 </html>

 

Here we have two <div> tags whose id's are child1, child2 and one <img> tag whose id is img1 with in parent <div> tag whose id is "parent".

 

We are applying jQuery mouseover() function to the parent <div> tag by using $('#parent').mouseover(function() {   }. Within this function we are applying our required properties to different elements.

 

                 $('#child1').css({
                    'background-color': 'green',
                    'font-weight': 'bold',
                    'color': 'red'
                });
             $('#child2').css({
                    'background-color': 'cyan',
                    'font-weight': 'bold',
                    'color': 'blue'
                });


will change the  font color and background color of our two <div> tags to our required colors whenever we place mouse on it.

 

                 $('#img1').css({
                    'opacity':1.0                   
                 });

 

will make the image bright whenever we place the mouse on it.

 

Here we are also using the jQuery mouseout() function to roll back the changes of our elements.

 

       $('#parent').mouseout(function() {
                $('#child1').css({
                    'background-color': 'white',
                    'font-weight': 'normal',
                    'color': 'black'
                });

                $('#child2').css({
                    'background-color': 'white',
                    'font-weight': 'normal',
                    'color': 'black'
                });

                $('#img1').css({
                    'opacity': 0.4
                });              
            });

 

will change the text font color, background color to black, white and will make the image blurred whenever mouse out from the content.

 

Download source code: jQuery_higlight_text_image.zip (41.89 kb)

Comments

3/5/2010 5:04:17 AM #

Aleshia Bendana

Personally, I found that migrating from Python version 2 to 3 was primarily a matter of relearning a few things: It certainly wasn’t as drastic a transfer as going from Python to say the Java or Perl languages. Numerous of the modifications have been long predicted, such as true division and changes to dict. Executing a print() is a whole bunch cleaner than System.out.println() in Java, so the learning curve is comparatively lesser and there are rewards to be gained.

Aleshia Bendana

3/5/2010 12:42:03 PM #

Johnny Pets

Hello, I often read your blog.I love it, Keep up the good work. Have you ever thought about blogging for money? there is a website http://www.abused-pets.com that pays you to write articles, you would be good at it.

Johnny Pets

3/16/2010 7:10:16 AM #

Abogado Laborista

I really appreciate this your good article

Abogado Laborista

3/16/2010 10:31:01 PM #

Link Building Guy

Green Day rocks! Billie Joe knows his stuff. I wish I could make some good songs out of simple guitar chords.

Link Building Guy

3/19/2010 9:03:59 AM #

Della Starcevich

Good day I just wanted to ask on what is the difference between blogenenigne and wordpress blogs? Is it easier to use or more efficient? I amseeing a lot of blogs powered by this software popping up lately and wondering if it is better or not? Thanks...

Della Starcevich

3/29/2010 3:50:27 AM #

Katherin Santella

Hey man, nice blog! I am signing up for your RSS feed.

Katherin Santella

4/3/2010 4:32:50 AM #

sample change order form

<A HREF="http://fitpress.com/johannessen/?p=4">contracts construction</A>

sample change order form

4/3/2010 2:47:40 PM #

wypożyczalnia samochodów dostawczych

Jamorama i think you have a great site here... today was my first time coming here.. i just happened to find it doing a google search. anyway, great post.. i'll be bookmarking this page for sure.

wypożyczalnia samochodów dostawczych

4/3/2010 8:39:22 PM #

hot scripts

I like the blog, but could not find how to subscribe to receive the updates by email.

hot scripts

4/3/2010 10:02:10 PM #

Pat

Hey guys I just wanted to ask you all check out <A href="http://www.helphaitinow.org">www.helphaitinow.org</A>&nbsp;and give money to help out the people of Haiti. Thanks...

Pat

4/4/2010 1:06:28 PM #

Million abstauben

Just want to say your article is stunning. The clarity in your post is simply impressive and i can take for granted you are an expert on this subject. Well with your permission allow me to grab your rss feed to keep up to date with forthcoming post. Thanks a million and please keep up the effective work.

Million abstauben

4/4/2010 5:52:20 PM #

script list

I like the blog, but could not find how to subscribe to receive the updates by email.

script list

4/5/2010 11:16:38 AM #

link building website

This is a good blog post. I am signing up for your feed

link building website

4/9/2010 4:02:08 AM #

0% credit cards

Many thanks for your guide!

0% credit cards

4/13/2010 8:06:38 AM #

faxless payday loan

@Walter I was trying to send you an email but I got the "Delivery to the following recipient failed permanently" error. It looks like you wrote your email wrong. Can you please contact me?

faxless payday loan

4/14/2010 3:19:52 AM #

coach rental london

Hi, I think this blog is helpful, I searched for it in Google and I'll note it!
Leeanna Charlson writing from British Isles.

coach rental london

4/17/2010 10:12:30 AM #

Online Tagesgeldkonten Vergleich

Thanks for your exciting post! I really enjoyed reading it, you are a great writer. I will make sure to bookmark your blog and come back soon. Keep up that great job, have a nice day!

Online Tagesgeldkonten Vergleich

4/23/2010 8:00:45 PM #

babyliss curling iron

I just want to emphasize the good work on this blog, has excellent views and a clear vision of what you are looking for.

babyliss curling iron

4/24/2010 1:42:05 AM #

3 barrel curling iron

It’s hard to find knowledgeable people on this topic, but you sound like you know what you’re talking about! Thanks

3 barrel curling iron

4/24/2010 9:27:32 AM #

Mel Branscombe

Great Post. Niftier then the simillar post I checked yesterday on Wordpress. Maintain the good work.

Mel Branscombe

4/24/2010 10:50:11 PM #

Hubert Cirone

Terrific Blog. Niftier then the simillar post I seen last Tuesday on AOL. Maintain the good work.

Hubert Cirone

4/26/2010 3:34:16 AM #

Hypercom T7Plus

The volcano and earthquake stuff seems to be coming frequently lately!

Hypercom T7Plus

4/27/2010 3:21:15 AM #

Hypercom T7Plus Manual

The volcano and earthquake happenings seems to be coming frequently a lot!

Hypercom T7Plus Manual

4/28/2010 11:42:49 PM #

Dwayne Lockmiller

You have definitely made some excellent points here. I specifically appreciate the way you've been able to stick so much thought into a relatively short submit (comparitively) which makes it an thoughtful submit on your subject. IMHO you put lots of great information in this publish with out all the filler that most bloggers use just to make their posts appear longer, that is ideal for a gal like me who doesn't have a lot time cause I'm usually within the go. I normally get so frustrated with so a lot of from the outcomes inside the major SE's since they generally seem to mostly be filled with filler content that normally isn't quite sensible. If you don't mind I'm going to add this submit and your weblog to my delicious favorites so I can share it with my family. I'll be back, you might be sure of that so keep up the great blogging.

Dwayne Lockmiller

4/29/2010 5:08:26 AM #

Elmo Stien

You have actually made some excellent points here. I particularly liked how you fit so a lot valuable data into such a concise blog post which created it truly enjoyable to read your thoughts for the topic. IMHO you put lots of excellent facts in this article without all the filler that most bloggers use just to make their posts appear longer, which is ideal for a gal like me who doesn't have considerably time cause I'm usually about the go. So numerous on the results on search engines are just unintelligible junk, it is nice to see a post that creates sense. I will definitely be adding this blog to my favorites list so I can share it with my friends. I appear forward to coming back to read your future posts also.

Elmo Stien

5/1/2010 6:03:54 PM #

Thu Wolfrom

Hello webmaster can I use some of the information from this post if I provide a link back to your site?

Thu Wolfrom

5/2/2010 8:33:04 AM #

Leo Kotlar

Intresting post, i really enjoyed reading it. :)

Leo Kotlar

5/11/2010 9:09:06 PM #

Jerry Mcneal

Thanks for posting this article. I'm decidedly frustrated with struggling to search out pertinent and intelligent commentary on this issue. Everybody today goes to the very far extremes to either drive home their viewpoint that either: everyone else in the planet is wrong, or two that everyone but them does not really understand the situation. Many thanks for your concise, pertinent insight.

Jerry Mcneal

5/14/2010 12:13:37 AM #

advice breaking up

Hands down, Apple's app store wins by a mile. It's a huge selection of all sorts of apps vs a rather sad selection of a handful for Zune. Microsoft has plans, especially in the realm of games, but I'm not sure I'd want to bet on the future if this aspect is important to you. The iPod is a much better choice in that case.

advice breaking up

5/14/2010 5:23:39 AM #

flash game

It is my very first time that i visit this blog. I recently uncovered plenty of exciting stuff in your weblog most definitely this blog page. From the plenty of responses on your articles, I suppose I'm not the only one experiencing all the enjoyment here!

flash game

5/14/2010 9:07:08 AM #

Buy JWH-018 Online

Why is JWH-018 legal? It does the same thing as marijuana, but better.

Buy JWH-018 Online

5/14/2010 3:55:27 PM #

oral hcg online

I hope you know that it is my pleasure to tweet and to post to google, and I'll be back to show my friends!

oral hcg online

5/15/2010 8:04:33 PM #

Carmella Esson

I am quite interesting in this topic hope you will elaborate more on it in future posts.

Carmella Esson

5/16/2010 12:18:06 AM #

desks home

I find that the harder I work, the more luck I seem to have.

desks home

5/17/2010 10:59:43 PM #

where to farm at 80 for easy gold

If you're still on the fence: grab your favorite earphones, head down to a Best Buy and ask to plug them into a Zune then an iPod and see which one sounds better to you, and which interface makes you smile more. Then you'll know which is right for you.

where to farm at 80 for easy gold

5/18/2010 11:01:59 AM #

XML Jobs

Hey.....nice post!!

Awesome, No more words to explain :) :) :D just....cool blog.

XML Jobs

5/19/2010 12:17:56 PM #

ajit

dsfsdf

ajit

5/23/2010 2:57:21 PM #

country lamp shades

I completely agree with the above comment, the internet is with a doubt growing into the most important medium of communication across the globe and its due to sites like this that ideas are spreading so quickly.

country lamp shades

5/24/2010 1:24:03 AM #

halogen desk lamp

I recently came accross your blog and have been reading along. I thought I would leave my first comment. I dont know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

halogen desk lamp

5/28/2010 10:45:05 AM #

raised bed gardening

Hi, I can’t understand how to add your site in my rss reader. Can you Help me, please :)

raised bed gardening

5/28/2010 11:28:41 PM #

ryobi 18v hedge trimmer

I like this site and saw it on Ask search. I guess your thoughts on how to make image bright and how to change text color dynamically are right on. Thanks for writing about this and looking forward to reading more on your site.

ryobi 18v hedge trimmer

5/29/2010 9:13:49 PM #

Delicia Hagens

As a Newbie, I am always searching online for articles that can help me. I always wanted to write in my site something like that. Can I take part of your post to my blog?

Delicia Hagens

5/29/2010 9:28:11 PM #

Forrest Biddiscombe

Of course, what a great site and informative posts, I will add backlink - bookmark this site? Regards, Fitness maniac.

Forrest Biddiscombe

5/30/2010 12:47:04 AM #

Delorse Holste

I usually don’t post in Blogs but your blog forced me to, amazing work.. beautiful …

Delorse Holste

6/16/2010 6:32:50 AM #

mmo

I was very thrilled to locate this site on yahoo.I wished to say many thanks to you with regard to this excellent read!! I certainlyliked every little bit of it and I've you bookmarked to have a look at new stuff you post.

mmo

6/17/2010 9:32:45 AM #

weight loss tips

This is insightful. Always weary about attaching my firm to other organizations for exactly this reason. I find the best comments are those that open up a discussion and invite conversation. Don’t understand why you wouldn’t want to have comments allowed on a blog- it doesn’t allow for a relationship with your readers.

weight loss tips

6/18/2010 10:03:32 AM #

Cheyenne Pompilio

Found your web site and decided to use a fast read, not what a usually do but nice one. Nice to see a blog for any change that isn’t full of spam and rubbish, and in fact makes some sense. Anyway, wonderful write up.

Cheyenne Pompilio

6/26/2010 7:02:07 AM #

moshi monsters

http://greenvillescbankruptcy.blogspot.com/2010/06/how-can-greenville-bankruptcy-attorney.html

moshi monsters

6/29/2010 5:21:00 AM #

Best Penis Enlargement Product

That was one particular with the most beneficial posts I've viewed in a extended lengthy time. A lot of appreciated, I�m planning to have to hang around here extra.

Best Penis Enlargement Product

6/30/2010 2:31:59 AM #

Audie Acebedo

Heya dude, haha ...what has happened??l your website is pretty unsightly in my cell phone internet browser! But I'm loving the content so awesome job. Incidentally, you can get <a href="http://www.clubseo.net">free web site design</a> at ClubSEO.net. It's a really good means to get your key website more visible as well! Take a visit if you have a minute. I did a couple of sites there and just pointed them all back to my blog and I get tons of new relevant subscribers now. Anyway, bless you for the shizzle man. Have a exceptional summertime and things! :D

Audie Acebedo

6/30/2010 3:15:01 AM #

Kerry Badamo

Here is the second occasion I've encountered your web sites within the last few weeks.  Seems as if I should take note of it.

Kerry Badamo

6/30/2010 4:10:46 AM #

Roland Vestal

Hey very good blog!!!! Wow... Gorgeous .. Amazing .. I’ll bookmark your weblog and take the feeds also...

Roland Vestal

6/30/2010 6:21:28 PM #

Best Penis Enlargement Product

What theme is this weblog employing? I know it is a web site engine website but I�ve by no means noticed this palette just before.

Best Penis Enlargement Product

7/3/2010 11:54:52 PM #

busy do Holandii

I stumbled across your blog and think it's fantastic, keep us posting

busy do Holandii

7/4/2010 8:11:46 AM #

registry cleaners

Thanks very much for the information. I have been looking for this for awhile with Yahoo and it has been a real chore.

registry cleaners

7/4/2010 8:09:58 PM #

sex herbs

Experience shows that success is due less to ability than to zeal. The winner is he who gives himself to his work, body and soul. Charles Buxton

sex herbs

7/9/2010 4:51:01 AM #

male enhancement

I feel bad with regard to guys that don't have considerably of a sex life. They're truly missing out on a beautiful component of life, and I'm creating sure I'm not missing it myself.

male enhancement

7/20/2010 4:41:32 AM #

Hypercom t7Plus manual

Well that makes 2 things that I learned this week.  This and google now has a ton of greasemonkey scripts which I never knew about.  You learn something every day?  I got more than what I bargained for! hahaha.

Hypercom t7Plus manual

7/25/2010 6:07:20 PM #

registry cleaners

I think most people would agree with your post. I am going to bookmark this web site so I can come back and read more posts. Keep up the great work!

registry cleaners

7/27/2010 7:00:09 PM #

Earlie Oskins

jquery mouseover THIS IS ROCK SOLID.

Earlie Oskins

7/28/2010 7:29:15 AM #

Free iPhone

Extremely inspiring. It's amazing what can be done when we put our minds to it.

Free iPhone

7/28/2010 7:44:04 PM #

Kym Pineault

Useful site, where did you invent some the knowledge with this posting? I am pleased I discovered it though, ill be checking back soon to see what extra posts you have.

Kym Pineault

Add comment




  Country flag

Click to change captcha
biuquote
  • Comment
  • Preview
Loading



Page List

    Tag cloud