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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:55:03+00:00 2026-06-09T20:55:03+00:00

<div class=test-test-one>one</div> <input type=checkbox class=now name=here_one> <br /> <div class=test-test-two>two</div> <input type=checkbox class=now name=here_two>

  • 0
<div class="test-test-one">one</div>
<input type="checkbox" class="now" name="here_one"> <br />

<div class="test-test-two">two</div>
<input type="checkbox" class="now" name="here_two"> <br />

<div class="test-test-three">three</div>
<input type="checkbox" class="now" name="here_three"> <br />

<div class="test-test-four">four</div>
<input type="checkbox" class="now" name="here_four"> <br />

​
FIDDLE: http://jsfiddle.net/3eUEp/

I would like doing:

if i click on checkbox with name = here_one then this should be add class .red to div with class test-test-one
and if i click on div with class test-test-one then also should be checked checkbox with name = here_one.

How can i make it with jQuery? i dont want use prev and next. I would like use selectors, but how to use substr from PHP for 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-06-09T20:55:05+00:00Added an answer on June 9, 2026 at 8:55 pm

    Here is the javascript documentation : http://www.w3schools.com/jsref/

    And jQuery : http://docs.jquery.com/Main_Page

    $('.now').click(function(){
        var v = $(this).attr('name').replace('here_', '');
    if($(this).is(':checked'))  
    {
            $('.test-test-'+v).addClass('red');
        }
        else
        {
            $('.test-test-'+v).removeClass('red');
        }
    });
    
    
    $("div[class^='test-test']").click(function(){
        if($(this).hasClass('red'))
        {
            $(this).next('.now').attr('checked', false);
            $(this).removeClass('red');
        }
        else
        {
            $(this).next('.now').attr('checked', true);
            $(this).addClass('red');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the html structure: <div id=test> <form> <input type=radio name=content class=s_code checked=checked /><span>code</span> <input type=radio
In my webpage, there's a div with a class named Test . How can
Suppose I have the following html: This a test of <code>some code</code>. <div class='highlight'>
<div> <div class="left"> <div align="center" class="node"> <div class="nodeText"> <h2 >test</h2> </div> <div class="node"> <h2>test</h2>
I have a String variable say strHTML = <div class='abc'> This is a test
<div class=test style=position:absolute; font-size: 12; right:400px; top:100px;><p>Hello</p></div> <div class=test style=position:absolute; font-size: 14; right:200px; top:140px;><p>Hello</p></div>
there are some code as this: <div class=test> <div class=upsell-tags> <?php echo $this->getChildHtml('product_additional_data') ?>
<div class=example> <div class=test style=display:none;>Text</div> </div> <div class=example> <div class=test style=display:none;>Some other text</div> </div>
I have html like: <fieldset> <div> <ul> <li class=test> This paragraph contains a very
Consider this sample code: <div class=containter id=ControlGroupDiv> <input onbeforeupdate=alert('bingo 0'); return false; onclick=alert('click 0');return

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.