Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Further Update:</strong> Working demo <a href="http://jsfiddle.net/Jb2jP/1/" rel="nofollow">http://jsfiddle.net/Jb2jP/1/</a></p> <pre><code>$(document).ready(function() { $(".menuA").click(function(evnt) { evnt.preventDefault(); $(".menuA").not(this).removeClass("menuA-open"); // hide all other fieldset objects except the one being toggled $('fieldset').not($(this).next('fieldset')).hide(); // toggle the fieldset following this link open or closed $(this).next('fieldset').toggle(); // toggle the currently selected menuA-open class on or off $(this).toggleClass("menuA-open"); }); $("fieldset").mouseup(function() { return false; }); $(document).mouseup(function(evnt) { // if user clicked anywhere outside our menus if ($(evnt.target).parent("a.menuA").length == 0) { // remove the menuA-open class from all class menuA objects $(".menuA").removeClass("menuA-open"); // hide all fieldset objects $("fieldset").hide(); } }); });​ </code></pre> <p><br /></p> <hr /> <p><strong>Update:</strong> To chain multiple attribute-(not)-equals selectors together, simply concatenate them (<a href="http://api.jquery.com/multiple-attribute-selector/" rel="nofollow">see jQuery docs</a>).</p> <pre><code>$(".menuA[name='abc'][type='123']").removeClass("menuA-open"); </code></pre> <p>Specifically in your case though, this still probably won't be necessary:</p> <pre><code>var type = $(this).attr('type'); $(".menuA").not(this).filter("[type='"type"']").removeClass("menuA-open"); </code></pre> <p><hr /> You can use the jquery <a href="http://api.jquery.com/not/" rel="nofollow"><code>.not()</code></a> filter method to remove the current element from the matched set once you've done the selection:</p> <pre><code>$(".menuA").not(this).removeClass("menuA-open"); </code></pre> <p>That is the way to do it.</p> <hr /> <p>As an example of how you <em>would</em> get your attempt working (not recommending this at all though):</p> <pre><code>$(".menuA[name!='" + $(this).text() +"']").removeClass("menuA-open"); </code></pre> <p>You need to wrap the results of <code>$(this).text()</code> in literal quotes within your string, since it contains a space. That should be the only syntactic problem, though again the <code>.not()</code> filter is the safest and most intuitive way to go about this.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload