Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery - Parents
    primarykey
    data
    text
    <p>I want to display either "OPEN" or "CLOSED", depending on the conditional, in the parent, but I don't know how to do this. This code makes two <code>&lt;h2&gt;</code> headings work as a drop down list. I want the function to pass the parameters, and if it does not equal 1, I want to display OPEN in the <code>&lt;span&gt;</code> of the <code>&lt;h2&gt;</code>.</p> <p><strong>Javascript</strong></p> <pre><code>&lt;script type="text/javascript"&gt; var a = null; var b = null; var c = 1; $(document).ready(function () { $(".toggle_container").hide(); $("h2.trigger").click(function () { $(this).toggleClass("active").next().slideToggle("slow"); }); }); function divide(a, b) { (a / b != c) ? // Where help is needed // $(this).parent(".status").text("OPEN").css("color", "green") : // $("team").parent(".status").text("CLOSED").css("color","red"); document.write(a + " / " + b); } &lt;/script&gt; </code></pre> <p><strong>HTML</strong></p> <pre><code> &lt;body&gt; &lt;div class="tournaments"&gt; &lt;h2 class="trigger"&gt;Tournament 1&lt;span class="status"&gt;&lt;/span&gt;&lt;/h2&gt; &lt;div class="toggle_container"&gt; &lt;div class="block"&gt; &lt;h3&gt;Details&lt;/h3&gt; &lt;p&gt;Deadline: DATE&lt;/p&gt; &lt;p&gt;Teams: &lt;span class="team"&gt;&lt;script type="text/javascript"&gt;divide(3, 7)&lt;/script&gt;&lt;/span&gt; &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;h2 class="trigger"&gt;Tournament 2 &lt;span class="status"&gt;&lt;/span&gt;&lt;/h2&gt; &lt;div class="toggle_container"&gt; &lt;div class="block"&gt; &lt;h3&gt;Details&lt;/h3&gt; &lt;p&gt;Deadline: DATE&lt;/p&gt; &lt;p&gt;Teams: &lt;span class="team"&gt;&lt;script type="text/javascript"&gt;divide(3,7)&lt;/script&gt;&lt;/span&gt; &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&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.
    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