$(function(){
if ($('#videoId').val){
var thisid = $('#videoId').val;
$("#videolist li[id$='vid-"+thisid+"]").addClass('selected');
}
});
.
<ul id="videolist">
<li id="vid-28">Option</li>
<li id="vid-29">Another Option</li>
<li id="vid-30">Third Option</li>
</ul>
I want the li with the id that matches the value of the input to be assigned the ‘selected’ class.
The code is commented out right now because it’s causing an endless loop, but also when I trace my thisid variable it gets an extremely long value that looks like jquery code.. I have ‘value’ working elsewhere, so I do not know what’s causing that.
You only need this as well: