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 1053705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:17:40+00:00 2026-05-16T17:17:40+00:00

I am trying to unselect the other div i click on before. i have

  • 0

I am trying to unselect the other div i click on before. i have stored the old div id in an hidden input as you can see below i have added a alert so show the last div selected and it works fine but as soon as i try and change the div text color in css the whole script stops working.

 function edit_addon(div_id) {   
 $("#"+div_id).attr('contentEditable', true);
 $("#"+div_id).html()
 $("#"+div_id).css('color','#F00');
 $("#"+div_id).css('cursor','Text');


 var old_div = $("input#selected_div").val();
 alert(old_div);
 $("#"+old_div).css('color','#000');

 $("input#selected_div").val(div_id);

 } 
  • 1 1 Answer
  • 1 View
  • 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-16T17:17:41+00:00Added an answer on May 16, 2026 at 5:17 pm

    Are you sure the alert works fine? It should not work on the first pass because there was no value for selected_div until the first call to edit_addon.

    Modify the code to:

    function edit_addon (div_id) {   
        $("#"+div_id).attr ('contentEditable', true)    //-- Use no semicolon here
                     .css ('color','#F00')
                     .css ('cursor','Text')
                     ;
    
        var old_div = $("input#selected_div").val();
        alert(old_div);
        if (old_div)
            $("#"+old_div).css('color','#000');
    
        $("#selected_div").val(div_id);
    } 
    

    .
    You can see it in action at jsfiddle. If you do, note that by changing the function to an event handler (as shown at jsfiddle) you can simplify the HTML and bind the function in a progressive-enhancement way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

trying to figure out why this is happening - I have an input text
I'm trying to implement the keyword Unselect Frame with selenium-webdriver, but have no idea
Trying to do something really simple, but can't figure out the syntax. I have
I am trying to create a select all, unselect all options like we see
Trying to figure out how I can do this properly. The print_r looks like
I have noticed when I am trying to implement the dayClick: and the select
Trying to randomly generate one div from an array on each load of a
Trying a simple project to create my own (very basic) data binding. I have
Trying to loop thru a result that has items. Items have a type and
Trying to use a DataGridView like the old VB6 FlexGrid, and add the coloumns

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.