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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:15:45+00:00 2026-05-27T22:15:45+00:00

I have a javascript tree, where user selects a tree node and clicks on

  • 0

I have a javascript tree, where user selects a tree node and clicks on a button which then appends an icon next to that selected tree node.

Here is the source code of one node in that tree:

<li node_id="4" name="mars" >
<ins class="jstree-icon"> </ins>
<a href="#" class="jstree-clicked"><ins class="jstree-icon"> </ins> Mars Planet 
    <a style="cursor: default;"><ins class="pattern-icon3"> </ins></a> <!--this line displays the icon-->
    <a style="cursor: default;"><ins class="pattern-icon3"> </ins></a> <!--this line displays the same icon again-->
</a>
</li>
.
.
.

Below is the code i use to append the icon next to the tree node.

$j("li[name='"+node_name+"'] > a").append('<a style="cursor:default;"><ins class="' + icon_class + '">&nbsp;</ins></a>');

The icon is displayed correctly.

My problem is:

I need to display a particular icon once only.
Currently, when user selects a node and clicks on the button twice, 2 icons are appended next to that selected node.

Is there a way of checking whether <a style="cursor: default;"><ins class="pattern-icon3"> </ins></a> is already appended next to the node name before it is added?

  • 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-27T22:15:45+00:00Added an answer on May 27, 2026 at 10:15 pm

    You can try matching the element with find() and appending it only if the match failed:

    var listItemLink = $j("li[name='" + node_name + "'] > a");
    if (!listItemLink.find("." + icon_class).length) {
        listItemLink.append('<a style="cursor:default;"><ins class="'
            + icon_class + '">&nbsp;</ins></a>');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have JavaScript that is doing activity periodically. When the user is not looking
I have a tree view which has a folder icon by default and once
I have a javascript function that walks a tree recursively. It has two flag
So I have this JavaScript literal that is displaying a tree structure using arborjs.
I have a javascript array which defines an infinite tree like this. z=['~GROUPHEAD 0~',
I am writing some UI tests using Selenium and i have a JavaScript Tree
I am trying to have a javascript object tree behave like a php associative
I have Javascript that opens another window and registers a click handler for all
I have JavaScript code which copies the value of input file and paste it
I have javascript string variable with var sttr=We prefer questions that can be answered

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.