Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to select an image outside of div if there is an image with jquery
    primarykey
    data
    text
    <p>The following HTML is output from a CMS. (Yes, it is from the last century)</p> <p>There could be an image or no image outside of #product_cont. The following code has an image. </p> <p>And if there is, there will be only one image outside #product_cont.</p> <p>Now I'd like to select the image outside of #product_cont if it exist. </p> <pre><code>... ... &lt;div id="system"&gt; &lt;FORM ACTION="command.asp" METHOD="get" NAME="artForm"&gt; &lt;TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"&gt; &lt;TR&gt; &lt;TD VALIGN="top"&gt; &lt;H1&gt;Lian Li PC-B25FB, Miditower, Sort&lt;/H1&gt; &lt;div id="product_cont"&gt; &lt;p&gt;&lt;img border="0" alt="" src="http://www.website.com/10157_00.jpg" /&gt; &lt;img border="0" alt="" src="http://www.website.com/10157_01.jpg" /&gt; &lt;img border="0" alt="" src="http://www.website.com/10157_02.jpg" /&gt; &lt;img border="0" alt="" src="http://www.website.com/10157_03.jpg" /&gt; &lt;!-- Maybe more images here --&gt;&lt;/p&gt; Testing testing &lt;/div&gt;&lt;!-- End of #system --&gt; &lt;/TD&gt; &lt;TD&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt; &lt;TD VALIGN="top" CLASS="td-main"&gt; &lt;P ALIGN="center"&gt; &lt;IMG SRC="images/articles/10031%5F1%2Ejpg" BORDER="0" ALT="Lian Li PC-B25FB, Miditower, Sort"&gt; &lt;!-- in some pages there won't be any images here --&gt; &lt;/P&gt; &lt;BR&gt; &lt;TD VALIGN="top" CLASS="td-main"&gt; ... ... &lt;TD VALIGN="top" CLASS="td-main"&gt; ... </code></pre> <p>I tried $("#system img:last"), it will select the last image in #system when there is no image outside #system.</p> <p>I assume I need to use if statement as well.</p> <p>Could anyone tell me how to do it with jquery please?</p>
    singulars
    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