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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:35:24+00:00 2026-06-02T17:35:24+00:00

Possible Duplicate: How do I select text nodes with jQuery? I am trying to

  • 0

Possible Duplicate:
How do I select text nodes with jQuery?

I am trying to move the data that is in the text node adjacent to a checkbox on the selection of the checkbox. I am using jquery. The methods I have tried are listed below with the results I received.

<input class="item" type="checkbox" /> Category 1
<input class="item" type="checkbox" /> Category 2


<script>
  $('.item').click(function(){
      if($(this).attr('checked'))
      {
         $('#list').append("<span>" + $(this).next() + "<span><br/>")
         //$(this).next() just writes "[object Object]"
         //$(this).next().text() doesn't write anything
         //Also tried $(this).nextSibling.nodeValue but throws "Cannot access property of undefined"
      }
      else
      {
          //This is remove the item from the list on uncheck 
      }
  });
</script>
  • 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-02T17:35:26+00:00Added an answer on June 2, 2026 at 5:35 pm

    Consider having this markup instead

    <input class="item" type="checkbox" id="cat_one" name="cat_one" /> <label for="cat_one">Category 1</label>
    <input class="item" type="checkbox" id="cat_two" name="cat_two"/> <label for="cat_two">Category 2</label>
    

    or this:

    <label for="cat_one"><input class="item" type="checkbox" id="cat_one" name="cat_one" /> Category 1</label>
    <label for="cat_two"><input class="item" type="checkbox" id="cat_two" name="cat_two"/> Category 2</label>
    

    Thus you kill two birds with one stone: a) your markup is far semantically better and b) you can access the label elements content via the .text() method.

    The first variant can be seen here: http://jsfiddle.net/skip405/DjWcg/

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

Sidebar

Related Questions

Possible Duplicate: How to select html nodes by ID with jquery when the id
Possible Duplicate: Focus input field with JQuery without selecting current value text Using the
Possible Duplicate: How to get all options of a select using Jquery? I have
Possible Duplicate: Select values of checkbox group with jQuery In HTML I have a
Possible Duplicate: Select inner text (jQuery) I have a span: <span class=test> target_string </span>
Possible Duplicate: jQuery select based on text I have something like this: <span>abc</span> <span>a</span>
Possible Duplicate: How do I randomly select an item from a list using Python?
Possible Duplicate: SELECT INTO using Oracle I have one table in my oracle database.
Possible Duplicate: SQL Select within 24 hours? I am using regular SQL to attempt
Possible Duplicate: How to select an element by class inside “this” in Jquery I'm

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.