Check if elements or html tags exist
<p>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.</p>

<p>Here is the source code of one node in that tree:</p>

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

<p>Below is the code i use to append the icon next to the tree node.</p>

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

<p>The icon is displayed correctly.</p>

<p><strong>My problem is:</strong></p>

<p>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.</p>

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