I am trying to click one of my LI thumbnails. The HTML code for this is:
<ul id="thumbImgs" class="list" style="height: 250px;">
<li id="04_BOARDWALK_VIEW.jpg" data-wh="1000|700|testing 3" class="item">
<img src="cms/img/uploaded/04_BOARDWALK_VIEW_tmb.jpg" width="120" height="120" class="imgStyle" style="opacity: 0.5;">
</li>
etc etc....
</ul>
I’ve already tried:
$('#04_BOARDWALK_VIEW.jpg').click();
$("#thumbImgs li #04_BOARDWALK_VIEW.jpg").click();
$("#thumbImgs li 04_BOARDWALK_VIEW.jpg").click();
But that does not seem to work. What would i be missing?
The problem you have is the period in your id. That is generally poor practice, but can be overcome in jQuery if you escape the period in the selector. Do it like this:
Note the need for double backslash as
\is an escapes charater in javascript, so you need one backslash to actually escape the real backslash which is needed by jQuery to escape the period. Again, best practice would have you not using the periods in the id’s at all.