Note that there are some explanatory texts on larger screens.

plurals
  1. POOptional parameters in JQuery seletor?
    primarykey
    data
    text
    <p>I'm trying to make a selector in JQuery that will fade in an element on multiple lists when anywhere on the document is clicked. Right now there are two lists, <code>kiosks</code> and <code>profiles</code>. The code I'm using for the function looks like this:</p> <pre><code>$(document).on('click', function( e ){ $( '.profile:not(".default") .name:not(".selected") .rename' ).fadeIn(80); $( '.kiosk .name:not(".selected") .rename' ).fadeIn(80); }); </code></pre> <p>Is there any way that I could add an optional selector, so that if the item is a profile that it also excludes the <code>default</code>, but otherwise any name uses these rules?</p> <p>EDIT: What I'm trying to do is to make that function into one line, so that it would be something like this: </p> <pre><code>$(document).on('click', function( e ){ $( '[profile:not("default") .name:not("selected") .rename' ).fadeIn(80); }); </code></pre> <p>Here is the HTML with the data bindings attached: </p> <pre><code> &lt;!-- Profiles --&gt; &lt;div class="profiles"&gt; &lt;h1&gt;Profiles&lt;/h1&gt; &lt;div data-bind="template: { name: 'profilestempl', foreach: $root.profiles }"&gt;&lt;/div&gt; &lt;/div&gt; &lt;script type="text/html" id="profilestempl"&gt; &lt;div class="profile" data-bind="css: { 'default' : !canChange() }"&gt; &lt;div class="name" data-bind="css: { 'selected' : isSelected }"&gt; &lt;input type="text" data-bind="hasfocus: $data.isSelected, value: tempName, enable: canChange(), valueUpdate: 'keyup'" /&gt; &lt;span class="rename" data-bind="click: $root.selectProfile"&gt;q&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;/script&gt; &lt;!-- Kiosks --&gt; &lt;div class="kiosks"&gt; &lt;h1&gt;Kiosks&lt;/h1&gt; &lt;div data-bind="template: { name: 'kioskstempl', foreach: $root.kiosks }"&gt;&lt;/div&gt; &lt;/div&gt; &lt;script type="text/html" id="kioskstempl"&gt; &lt;div class="kiosk"&gt; &lt;div class="name" data-bind=" css: { 'selected' : isSelected }"&gt; &lt;input type="text" maxlength="30" data-bind="hasfocus:$data.isSelected, value:tempName, valueUpdate: 'keyup' " /&gt; &lt;span class="rename" data-bind="click: $root.selectKiosk"&gt;q&lt;/span&gt; &lt;/div&gt; &lt;select data-bind="options: $root.profiles, optionsText: 'name', value: profile"&gt;&lt;/select&gt; &lt;/div&gt; &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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