Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6575005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:20:02+00:00 2026-05-25T15:20:02+00:00

There are my codes: Jquery $(function() { $(#evtTarget).bind(mouseover,highlighted); $(#evtTarget).bind(mouseleave,highlighted); $(#evtTarget).bind(click,function(){ $(#evtTarget).unbind(mouseover,highlighted); $(#evtTarget).unbind(mouseleave,highlighted); $(#evtTarget).html(Off.Click for

  • 0

There are my codes:

Jquery

$(function() {
                $("#evtTarget").bind("mouseover",highlighted);
                $("#evtTarget").bind("mouseleave",highlighted);

                $("#evtTarget").bind("click",function(){
                    $("#evtTarget").unbind("mouseover",highlighted);
                    $("#evtTarget").unbind("mouseleave",highlighted);
                    $("#evtTarget").html("Off.Click for On.");

                    });
        });

        function highlighted(evt){
                $("#evtTarget").toggleClass("highlighted");
            }

Html

<h1>Binding Event Example</h1>
<div id="evtTarget" class="normal">On. Click for Off.</div>

Css

normal {
        width:300px;
        height:200px;
        background-color:red;
        font-size:18pt;
        color:black;
   }
.highlighted {
       background-color:white;
}

If you mouseover evtTarget id paragraph highligt. And if you click evtTarget id highlighting will be off.

But I want to if user click secondly highlighting is on.

How can i do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:20:03+00:00Added an answer on May 25, 2026 at 3:20 pm

    You could use the .data method (api) to save the whether or not highlighting is on:

    $(function() {
        $("#evtTarget").bind("mouseover",highlighted)
            .bind("mouseleave",highlighted)
            .data("isOn", true);
    
        $("#evtTarget").bind("click",function(){
    
            if($(this).data("isOn")) {
                $("#evtTarget")
                   .unbind("mouseover",highlighted)
                   .unbind("mouseleave",highlighted)
                   .removeClass("highlighted")
                   .html("Off:   Click for On.")
                   .data("isOn", false);
    
            } else {
                $("#evtTarget")
                   .bind("mouseover",highlighted)
                   .bind("mouseleave",highlighted)
                   .addClass("highlighted")
                   .html("On:   Click for Off.")
                   .data("isOn", true);                        
            }
       });
    });
    
    function highlighted(evt){
        $("#evtTarget").toggleClass("highlighted");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the jquery.cycle.js file, there is the following code: $.fn.cycle.transitions.scrollRight = function($cont, $slides, opts)
This is a weird one, but... We have this code: jQuery(function($) { $('#basic-modal .basic').click(function(e)
Is there a better way to do this jquery code? Currently I have to
I have some jQuery/JavaScript code that I want to run only when there is
There is an excellent code example on how to make nice jQuery Twitter style
Are there any codes that allow for numerical formatting of data when using string.format?
In some sample codes there are methods and classes declared WITHIN other methods and/or
There are sample codes on the net for OpenId Client but none for OpenId
There are quite a few of IRC server codes I am working on a
Since there are no C# source codes for Wait, Pulse, PulseAll methods. Does anyone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.