Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add event handlers to DIVS with CSS classes containing a particular string?
    text
    copied!<p>I want to be able to add some onclick event handlers to some DIV elements which are styled by CSS classes matching a particular string. The DIVS would be for a particular type of image which represents something called a Work Center in Discrete Event Simulation that I want users to be able to click on, change some settings, and run the simulation again.</p> <p>I'm using a system that was developed ages ago that handles these images like so:</p> <pre><code>&lt;div id="Decision__1" class="S8DisplayObject Image__for__Decision__1" style="top:35px; left:579px; width:118px; height:71px;"&gt;&lt;div id="Decision__1_textData_2" class="S8Web-TextData" style="left:-136px; top:-12px;"&gt;&lt;div class="noTextWrap"&gt;0&lt;/div&gt;&lt;/div&gt;&lt;div class="sb_block_display"&gt;&lt;/div&gt;&lt;/div&gt; &lt;div id="Decision__2" class="S8DisplayObject Image__for__Decision__2" style="top:35px; left:579px; width:118px; height:71px;"&gt;&lt;div id="Decision__2_textData_2" class="S8Web-TextData" style="left:-136px; top:-12px;"&gt;&lt;div class="noTextWrap"&gt;0&lt;/div&gt;&lt;/div&gt;&lt;div class="sb_block_display"&gt;&lt;/div&gt;&lt;/div&gt; </code></pre> <p>So it incrementally assigns a number to each class, and in this case, the string I would want to compare would be <code>Image__for__Decision</code>. Unfortunately I can't really delve into how these CSS classes are named, as they are part of a much larger conversion process.</p> <p>Any tips would be greatly appreciated!</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